You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have added "// highlight-start" and "// highlight-stop" to code sections, to highlight better the code in sections without highlighting...
I think is better to follow the logic of any explanation of how was done until here...
Thanks,
Armando
Copy file name to clipboardExpand all lines: src/content/6/es/part6a.md
+21-4Lines changed: 21 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -90,7 +90,9 @@ Cambiemos un poco el código. Es habitual usar el comando [switch](https://devel
90
90
Definamos también un [valor predeterminado](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters) de 0 para el <i>estado</i> del parámetro . Ahora el reducer funciona incluso si el estado del store aún no se ha indicado.
No se supone que Reducer se llame directamente desde el código de la aplicación. Reducer solo se proporciona como parámetro a la función _createStore_ que crea el store:
109
111
110
112
```js
113
+
// highlight-start
111
114
import { createStore } from'redux'
115
+
// highlight-end
112
116
113
117
constcounterReducer= (state=0, action) => {
114
118
// ...
115
119
}
116
120
121
+
// highlight-start
117
122
conststore=createStore(counterReducer)
123
+
// highlight-end
118
124
```
119
125
120
126
@@ -383,7 +389,9 @@ Agregamos una nueva nota al estado con el método _state.push(action.data)_ que
383
389
```js
384
390
constnoteReducer= (state= [], action) => {
385
391
if (action.type==='NEW_NOTE') {
392
+
// highlight-start
386
393
returnstate.concat(action.data)
394
+
// highlight-stop
387
395
}
388
396
389
397
return state
@@ -568,7 +576,9 @@ Agregar una nueva nota crea el estado que devuelve con la función de Arrays _co
568
576
constnoteReducer= (state= [], action) => {
569
577
switch(action.type) {
570
578
case'NEW_NOTE':
579
+
// highlight-start
571
580
return [...state, action.data]
581
+
// highlight-stop
572
582
case'TOGGLE_IMPORTANCE':
573
583
// ...
574
584
default:
@@ -754,42 +764,50 @@ Tu aplicación puede tener una apariencia modesta, nada más se necesitan 3 boto
754
764
Agreguemos la funcionalidad para agregar nuevas notas y cambiar su importancia:
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).
0 commit comments