Skip to content

Commit 5421c38

Browse files
committed
fix highlight
1 parent f22b115 commit 5421c38

File tree

2 files changed

+7
-18
lines changed

2 files changed

+7
-18
lines changed

src/content/6/en/part6a.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ const noteReducer = (state = [], action) => {
362362
if (action.type === 'NEW_NOTE') {
363363
// highlight-start
364364
return state.concat(action.payload)
365-
// highlight-stop
365+
// highlight-end
366366
}
367367

368368
return state
@@ -582,7 +582,7 @@ const noteReducer = (state = [], action) => {
582582
case 'NEW_NOTE':
583583
// highlight-start
584584
return [...state, action.payload]
585-
// highlight-stop
585+
// highlight-end
586586
case 'TOGGLE_IMPORTANCE':
587587
// ...
588588
default:
@@ -756,7 +756,7 @@ Let's add the functionality for adding new notes and changing their importance:
756756
// highlight-start
757757
const generateId = () =>
758758
Number((Math.random() * 1000000).toFixed(0))
759-
// highlight-stop
759+
// highlight-end
760760

761761
const App = () => {
762762
// highlight-start

src/content/6/es/part6a.md

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,7 @@ Agregamos una nueva nota al estado con el método _state.push(action.data)_ que
389389
```js
390390
const noteReducer = (state = [], action) => {
391391
if (action.type === 'NEW_NOTE') {
392-
// highlight-start
393392
return state.concat(action.data)
394-
// highlight-stop
395393
}
396394

397395
return state
@@ -576,9 +574,7 @@ Agregar una nueva nota crea el estado que devuelve con la función de Arrays _co
576574
const noteReducer = (state = [], action) => {
577575
switch(action.type) {
578576
case 'NEW_NOTE':
579-
// highlight-start
580577
return [...state, action.data]
581-
// highlight-stop
582578
case 'TOGGLE_IMPORTANCE':
583579
// ...
584580
default:
@@ -764,50 +760,42 @@ Tu aplicación puede tener una apariencia modesta, nada más se necesitan 3 boto
764760
Agreguemos la funcionalidad para agregar nuevas notas y cambiar su importancia:
765761

766762
```js
767-
// highlight-start
768763
const generateId = () =>
769764
Number((Math.random() * 1000000).toFixed(0))
770-
// highlight-stop
771765

772766
const App = () => {
773-
// highlight-start
774767
const addNote = (event) => {
775768
event.preventDefault()
776769
const content = event.target.note.value
777770
event.target.note.value = ''
778771
store.dispatch({
779772
type: 'NEW_NOTE',
780-
payload: {
773+
data: {
781774
content,
782775
important: false,
783776
id: generateId()
784777
}
785778
})
786779
}
787-
// highlight-end
788780

789-
// highlight-start
790781
const toggleImportance = (id) => {
791782
store.dispatch({
792783
type: 'TOGGLE_IMPORTANCE',
793-
payload: { id }
784+
data: { id }
794785
})
795786
}
796-
// highlight-end
797787

798788
return (
799789
<div>
800-
// highlight-start
801790
<form onSubmit={addNote}>
802791
<input name="note" />
803792
<button type="submit">add</button>
804793
</form>
805-
// highlight-end
806794
<ul>
807795
{store.getState().map(note =>
808796
<li
809797
key={note.id}
810-
onClick={() => toggleImportance(note.id)} // highlight-line
798+
onClick={() => toggleImportance(note.id)}
811799
>
812800
{note.content} <strong>{note.important ? 'important' : ''}</strong>
813801
</li>
@@ -818,6 +806,7 @@ const App = () => {
818806
}
819807
```
820808

809+
821810
La implementación de ambas funcionalidades es sencilla. Cabe señalar que <i>no hemos</i> vinculado el estado de los campos del formulario al estado del componente <i>App</i> como lo hicimos anteriormente. React llama a este tipo de formulario [no controlado](https://reactjs.org/docs/uncontrolled-components.html).
822811

823812

0 commit comments

Comments
 (0)