Javascript 我可以使用 Chrome Dev Tools 查看/修改 Redux 商店吗

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42340562/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 01:04:50  来源:igfitidea点击:

Can I view/modify the Redux store using Chrome Dev Tools

javascriptreactjsreduxgoogle-chrome-devtoolsreact-redux

提问by Andy Polhill

React Dev Tools is great for working with Redux, I can simply go in and modify props / state to see the affect on the relevant Container.

React Dev Tools 非常适合与 Redux 一起使用,我可以简单地进入并修改 props / state 以查看对相关容器的影响。

However if the required Container isn't mounted I need to directly modify the Redux store to make it appear. Is this possible with Chrome Dev Tools, I am able to find the Redux store, it is the top level <Provider />component, I can even see the getStatemethod, but is there anyway to modify the underlying state?

但是,如果未安装所需的 Container,我需要直接修改 Redux 存储以使其出现。使用 Chrome Dev Tools 是否可行,我可以找到 Redux 商店,它是顶级<Provider />组件,我什至可以看到该getState方法,但是无论如何要修改底层状态?

React dev tools Provider

React 开发工具提供者

回答by Marek Dorda

Yes, you can. There is a great Redux DevTools Extensionfor Chrome/Firefox/Electron which adds a new Redux tab to devtools:

是的你可以。Chrome/Firefox/Electron有一个很棒的Redux DevTools 扩展,它为 devtools 添加了一个新的 Redux 选项卡:

enter image description here

在此处输入图片说明

You can import and export current store, go back in history, change whatever you want and much more.

您可以导入和导出当前商店、返回历史、更改您想要的任何内容等等。