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
Copy file name to clipboardExpand all lines: src/content/6/en/part6b.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -659,13 +659,13 @@ The output is interesting but not very useful. This is about the previously ment
659
659
660
660
The status can be converted to a human-readable format by using the [current](https://redux-toolkit.js.org/api/other-exports#current) function from the immer library.
661
661
662
-
Update the imports to include the "current" function from the immer library:
662
+
Let's update the imports to include the "current" function from the immer library:
663
663
664
664
```js
665
665
import { createSlice, current } from'@reduxjs/toolkit'// highlight-line
666
666
```
667
667
668
-
Then update the console.log function call:
668
+
Then we update the console.log function call:
669
669
670
670
```js
671
671
console.log(current(state)) // highlight-line
@@ -713,7 +713,7 @@ Also, start using Redux DevTools to debug the application's state easier.
713
713
714
714
Change also the definition of the <i>anecdote reducer and action creators</i> to use the Redux Toolkit's <em>createSlice</em> function.
715
715
716
-
Implementation note: when you use the Redux Toolkit to return the initial state of anecdotes, it will be immutable, so you will need to make a copy of it to sort it, or you will encounter "TypeError: Cannot assign to read only property '". You can use the spread syntax to make a copy of the array. Instead of:
716
+
Implementation note: when you use the Redux Toolkit to return the initial state of anecdotes, it will be immutable, so you will need to make a copy of it to sort the anecdotes, or you will encounter the error "TypeError: Cannot assign to read only property". You can use the spread syntax to make a copy of the array. Instead of:
Copy file name to clipboardExpand all lines: src/content/6/es/part6b.md
+27-3Lines changed: 27 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,7 @@ Dado que el atributo <i>name</i> de todos los botones de radio es el mismo, esto
75
75
76
76
Los botones tienen un controlador de cambios que actualmente solo imprime el string asociado con el botón en el que se hizo clic en la consola.
77
77
78
-
Decidimos implementar la funcionalidad del filtro almacenando <i>el valor del filtro</i> en el store redux además de las notas mismas. El estado del store debería verse así después de realizar estos cambios:
78
+
En la siguiente sección, vamos a implementar el filtrado almacenando las notas y <i>el valor del filtro</i> en el store de redux. Cuando terminemos, nos gustaría que el estado del store se viera así:
79
79
80
80
```js
81
81
{
@@ -657,10 +657,18 @@ Lo siguiente se imprime en la consola
657
657
658
658
Lo que vemos es interesante pero no muy útil. Esto tiene que ver con la librería Immer que mencionamos anteriormente y es utilizada por Redux Toolkit internamente para guardar el estado de la Tienda.
659
659
660
-
El estado se puede convertir a un formato legible por humanos, por ejemplo, convirtiéndolo primero en un string y luego de nuevo en un objeto JavaScript de la siguiente manera:
660
+
El estado se puede convertir a un formato legible por humanos utilizando la función [current](https://redux-toolkit.js.org/api/other-exports#current) de la librería immer.
661
+
662
+
Actualicemos las importaciones para incluir a la función "current" de la librería immer:
663
+
664
+
```js
665
+
import { createSlice, current } from'@reduxjs/toolkit'// highlight-line
666
+
```
667
+
668
+
Luego actualicemos el llamado a la función console.log:
Ahora lo que imprime la consola es legible para humanos
@@ -705,6 +713,22 @@ También, comienza a utilizar Redux DevTools para depurar el estado de la aplica
705
713
706
714
Cambia también la definición de <i>anecdote reducer y sus action creators</i> para usar la función <em>createSlice</em> de Redux Toolkit.
707
715
716
+
Nota de implementación: cuando utilices Redux Toolkit para devolver el estado inicial de las anécdotas, será inmutable, por lo que tendrás que copiarlo para ordenarlas, o te encontraras con el error "TypeError: Cannot assign to read only property". Puedes usar la sintaxis spread para hacer una copia del array. En vez de:
717
+
718
+
```js
719
+
720
+
anecdotes.sort()
721
+
722
+
```
723
+
724
+
Escribe:
725
+
726
+
```js
727
+
728
+
[...anecdotes].sort()
729
+
730
+
```
731
+
708
732
#### 6.12 Mejores Anécdotas, paso 10
709
733
710
734
La aplicación tiene el esqueleto del componente <i>Notification</i> listo para utilizarlo:
0 commit comments