Skip to content

Commit da569e6

Browse files
authored
Update part6b.md
use the "current" function from the redux toolkit intended to print the state of the redux rather than using a workaround
1 parent 3e823bf commit da569e6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/content/6/en/part6b.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,18 @@ The following is printed to the console
657657
658658
The output is interesting but not very useful. This is about the previously mentioned Immer library used by the Redux Toolkit internally to save the state of the Store.
659659
660-
The status can be converted to a human-readable format, e.g. by converting it first to a string and then back to a JavaScript object as follows:
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+
662+
Update the imports to include the "current" function from the immer library:
663+
664+
```js
665+
import { createSlice, current } from '@reduxjs/toolkit' // highlight-line
666+
```
667+
668+
Then update the console.log function call:
661669
662670
```js
663-
console.log(JSON.parse(JSON.stringify(state))) // highlight-line
671+
console.log(current(state)) // highlight-line
664672
```
665673
666674
Console output is now human readable

0 commit comments

Comments
 (0)