湖南建设监理报名网站,重庆网站seo教程,网站建设 需求,怎样做网站分析调试react应用通常利用chrome的inspector的功能和两个最常用的扩展 1、React Developer Tools #xff08;主要用于debug组件结构) 2、Redux DevTools #xff08;主要用于debug redux store的数据#xff09; 对于react native应用#xff0c;我们一般就使用react-nativ…调试react应用通常利用chrome的inspector的功能和两个最常用的扩展 1、React Developer Tools 主要用于debug组件结构) 2、Redux DevTools 主要用于debug redux store的数据 对于react native应用我们一般就使用react-native-debugger了它是一个独立的应用需要单独安装在mac下可以用如下命令安装或到官网下载安装包
# mac 终端下使用如下命令安装 cask参数是针对安装有GUI界面的APP
brew install --cask react-native-debuggerRN工程添加依赖
RN工程中需要安装如下两个包
yarn add redux-devtools-extension remote-redux-devtoolsRN工程创建store的配置
# 引入 composeWithDevTools方法利用方法生成composeEnhancers并创建store实例
import {composeWithDevTools} from redux-devtools-extension;通常的常规用法
import { createStore, applyMiddleware } from redux;
import { composeWithDevTools } from redux-devtools-extension;const store createStore(reducer, composeWithDevTools(applyMiddleware(...middleware),// other store enhancers if any
));使用 Enhancers的情况
import { createStore, applyMiddleware } from redux;
import { composeWithDevTools } from redux-devtools-extension;const composeEnhancers composeWithDevTools({// Specify name here, actionsBlacklist, actionsCreators and other options if needed
});
const store createStore(reducer, /* preloadedState, */ composeEnhancers(applyMiddleware(...middleware),// other store enhancers if any
));具体的场景参考官方文档的指引 https://github.com/zalmoxisus/redux-devtools-extension#1-with-redux
RN调试
1、先启动react-native-debugger应用 2、然后按正常步骤开启RN应用的debug模式 3、最后没有任何异常的话就在react-native-debugger界面查看组件结构以及调试JS代码收集与分析store的数据变化了
查看network
默认的react-native-debugger的network监视是看不到react native 应用的网络请求的需要更改下react-native-debugger的配置 打开文件后修改defaultNetworkInspect的值为true然后重启后生效enjoy!
参考文档
https://github.com/zalmoxisus/redux-devtools-extension#1-with-reduxhttps://github.com/jhen0409/react-native-debuggerHow to use Redux devtools with React Native