I need to get the whole Redux state as a JSON file without payload or action from Redux DevTools, just the state.
Getting entire redux state as a separate JSON file
Asked Answered
If you're using React, and have React DevTools installed, there's another way to get the state from within Chrome:
Open React DevTools Components tab and select the top level "Provider":
Then go to the Console tab and paste this into the prompt: JSON.stringify($r.store.getState())
$r is the currently selected component in react devtools
Accepted this answer, as this one is better than previous –
Laurin
This worked for me
JSON.stringify($r.props.store.getState())
–
Ailsun This is a valid JS object, but it's not technically valid JSON as the keys need to be strings which need to be surrounded by quotes: json.org –
Tops
when I paste it into my editor and save as *.json it gets formatted correctly (with quotes, etc) 8) –
Bursarial
If you're using React, and have React DevTools installed, there's another way to get the state from within Chrome:
Open React DevTools Components tab and select the top level "Provider":
Then go to the Console tab and paste this into the prompt: JSON.stringify($r.store.getState())
$r is the currently selected component in react devtools
Accepted this answer, as this one is better than previous –
Laurin
This worked for me
JSON.stringify($r.props.store.getState())
–
Ailsun - Open Redux devTool => state => raw => Copy all the state
- Open the visual code, create a .json file and paste the state into this new file
- Install "Prettier" extension.
- Right click and choose "Format document with..."
It's done in my case :D
© 2022 - 2024 — McMap. All rights reserved.