我是靠谱客的博主 寒冷铃铛,这篇文章主要介绍React-Native调试工具DOM结构查看,现在分享给大家,希望可以做个参考。

Redux的调试,除了最基本的打断点进去调试之外,还有一个好用的调试工具reactotron,它能够帮你清楚的记录你所发出的action,以及http请求,可以帮你更好的分析redux的结构。

下面说一下简单的配置

  • package.json中的添加
复制代码
1
2
3
4
5
6
devDependencies: { "reactotron-apisauce": "^1.11.1", "reactotron-react-native": "^1.11.1", "reactotron-redux": "^1.11.2", "reactotron-redux-saga": "^1.11.1" }
  • 修改store.js文件
复制代码
1
2
3
4
5
6
7
8
9
10
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), );
  • ReactotronConfig.js文件
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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。

只需要在index.ios.jsindex.android.js文件中引入import 'react-devtools';即可。

复制代码
1
2
3
4
import 'react-devtools'; // 引入,需要执行`yarn add react-devtools ` import { AppRegistry } from 'react-native'; import APP from './src/APP'; AppRegistry.registerComponent('workflow', () => APP);

然后在

复制代码
1
2
3
4
5
6
7
//package.json中添加` "devtools": "react-devtools"` 类似下面这样 "scripts": { "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest", "devtools": "react-devtools" },

然后在命令行执行yarn run devtools即可。

配合ios模拟器可以方便进行查找dom元素。

qq20170915-140436@2x.png

最后

以上就是寒冷铃铛最近收集整理的关于React-Native调试工具DOM结构查看的全部内容,更多相关React-Native调试工具DOM结构查看内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(106)

评论列表共有 0 条评论

立即
投稿
返回
顶部