在调试一个Chrome插件的时候,第一次用到了Redux DevTools的远程模式,进而了解到React Native的开发朋友们平时都是怎么调试redux store的。
使用远程模式,需要App在启用Redux DevTool的基础上,再添加[remote-redux-devtools](https://github.com/zalmoxisus/remote-redux-devtools)这个库。按照Github上的指示,只需要做以下几件事:
安装
打开命令行工具,指向项目目录,运行以下命令行:
npm i remote-redux-devtools -D
修改创建Store代码
import {
createStore } from 'redux';
import devToolsEnhancer from 'remote-redux-devtools';
const store = createStore(reducer, devToolsEnhancer(options))

本文介绍了如何在React Native应用中使用Redux DevTools的远程模式进行调试。首先需要安装`remote-redux-devtools`库,并修改创建Store的代码,设置为连接本地服务器。接着安装并启动`remotedev-server`,确保hostname和port与Store配置一致。在开发模式下,通过设置环境变量启用远程调试。最后,在浏览器或Chrome插件中配置Redux DevTools连接本地服务器,实现远程调试。
最低0.47元/天 解锁文章
1617

被折叠的 条评论
为什么被折叠?



