Skip to content

Commit bcbb463

Browse files
authored
Merge pull request #3589 from pablo-maff/part6b
6b
2 parents 4ef32d5 + b98a668 commit bcbb463

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

src/content/6/en/part6b.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,13 @@ The output is interesting but not very useful. This is about the previously ment
659659
660660
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.
661661
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:
663663
664664
```js
665665
import { createSlice, current } from '@reduxjs/toolkit' // highlight-line
666666
```
667667
668-
Then update the console.log function call:
668+
Then we update the console.log function call:
669669
670670
```js
671671
console.log(current(state)) // highlight-line
@@ -713,7 +713,7 @@ Also, start using Redux DevTools to debug the application's state easier.
713713
714714
Change also the definition of the <i>anecdote reducer and action creators</i> to use the Redux Toolkit's <em>createSlice</em> function.
715715
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:
717717
718718
```js
719719

src/content/6/es/part6b.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Dado que el atributo <i>name</i> de todos los botones de radio es el mismo, esto
7575

7676
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.
7777

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í:
7979

8080
```js
8181
{
@@ -657,10 +657,18 @@ Lo siguiente se imprime en la consola
657657
658658
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.
659659
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:
661669
662670
```js
663-
console.log(JSON.parse(JSON.stringify(state))) // highlight-line
671+
console.log(current(state)) // highlight-line
664672
```
665673
666674
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
705713
706714
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.
707715
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+
708732
#### 6.12 Mejores Anécdotas, paso 10
709733
710734
La aplicación tiene el esqueleto del componente <i>Notification</i> listo para utilizarlo:

0 commit comments

Comments
 (0)