React-Native调试工具
发布时间:2020-12-15 06:39:26 所属栏目:百科 来源:网络整理
导读:Redux的调试,除了最基本的打断点进去调试之外,还有一个好用的调试工具 reactotron ,它能够帮你清楚的记录你所发出的action,以及http请求,可以帮你更好的分析redux的结构。 下面说一下简单的配置 package.json 中的添加 devDependencies: { " reactotron
Redux的调试,除了最基本的打断点进去调试之外,还有一个好用的调试工具reactotron,它能够帮你清楚的记录你所发出的action,以及http请求,可以帮你更好的分析redux的结构。
devDependencies: {
"reactotron-apisauce": "^1.11.1","reactotron-react-native": "^1.11.1","reactotron-redux": "^1.11.2","reactotron-redux-saga": "^1.11.1" }
import Reactotron from 'reactotron-react-native';
import { composeWithDevTools } from 'redux-devtools-extension';
import '../ReactotronConfig';
const sagaMiddleware = createSagaMiddleware({
sagaMonitor: Reactotron.createSagaMonitor(),});
const store = Reactotron.createStore(
xxReducer,composeWithDevTools(middleware),);
import Reactotron,{ networking } from 'reactotron-react-native';
import { reactotronRedux as reduxPlugin } from 'reactotron-redux';
import sagaPlugin from 'reactotron-redux-saga';
/* eslint no-console:0 */
console.disableYellowBox = true;
Reactotron.configure({ name: 'ReactNativeSinooa' }); // controls connection & communication settings
Reactotron.useReactNative(); // add all built-in react native plugins
Reactotron.use(reduxPlugin());
Reactotron.use(sagaPlugin());
Reactotron.use(networking());
// if we're running in DEV mode,then let's connect!
/* eslint no-undef:0 */
if (__DEV__) {
Reactotron.connect();
Reactotron.clear();
}
DOM结构查看可以查看dom结构的react devtools。 只需要在 import 'react-devtools'; // 引入,需要执行`yarn add react-devtools `
import { AppRegistry } from 'react-native';
import APP from './src/APP';
AppRegistry.registerComponent('workflow',() => APP);
然后在 //package.json中添加` "devtools": "react-devtools"`
类似下面这样
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start","test": "jest","devtools": "react-devtools"
},
然后在命令行执行 配合ios模拟器可以方便进行查找dom元素。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |