react native redux saga增加日志功能
redux-logger地址:https://github.com/evgenyrodionov/redux-logger
目前Reac native项目中已经使用redux功能,异步中间件使用redux saga,但在处理时,也需要增加redux打印日志的功能,所以需要增加redux-logger功能
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/ import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Text,
View
} from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome' //router
import { Router, Scene, Tabs } from 'react-native-router-flux'; //redux
import { createStore, applyMiddleware } from 'redux';
import { Provider } from 'react-redux'; //redux logger
import logger from 'redux-logger'; //reducers
import allReducers from './src/reducers'; //containers
import HomeContainer from './src/containers/HomeContainer';
import OrderContainer from './src/containers/OrderContainer';
import MainContainer from './src/containers/MainContainer';
//user containers
import UserLoginContainer from './src/containers/user/UserLoginContainer';
import UserRegisterContainer from './src/containers/user/UserRegisterContainer';
//check containers
import StyleCheckContainer from './src/containers/check/StyleCheckContainer';
import HandmadeCheckContainer from './src/containers/check/HandmadeCheckContainer';
import SizeCheckContainer from './src/containers/check/SizeCheckContainer';
import FittingCheckContainer from './src/containers/check/FittingCheckContainer';
//storage
import storage from './src/util/tqsStorage'; //mutil language
import I18n from './src/config/i18n'; //saga
import createSagaMiddleware from 'redux-saga';
import rootSaga from './src/sagas/rootSaga'; const sagaMiddleware = createSagaMiddleware();
let store = createStore(allReducers, applyMiddleware(logger,sagaMiddleware)); //run all saga function
sagaMiddleware.run(rootSaga); export default class App extends Component<{}> {
constructor(props) {
super(props);
this.state = {
}
}
componentDidMount() {
}
render() {
return (
<Provider store={store}>
<Router>
<Scene key='root'>
<Scene key='UserLogin' component={UserLoginContainer} title={I18n.t('App.UserLogin_Title')} initial={true} hideNavBar={true} />
<Scene key='UserRegister' component={UserRegisterContainer} title={I18n.t('App.UserRegister_Title')} />
<Scene key='Home' component={HomeContainer} title={I18n.t('App.Home_Title')} hideNavBar={true} />
<Scene key='Order' component={OrderContainer} title={I18n.t('App.Order_Title')} hideNavBar={true} />
<Scene key='Main' component={MainContainer} title={I18n.t('App.Main_Title')} hideNavBar={true} /> <Scene key='StyleCheck' component={StyleCheckContainer} title={I18n.t('App.StyleCheck_Title')} hideNavBar={true} />
<Scene key='HandmadeCheck' component={HandmadeCheckContainer} title={I18n.t('App.HandmadeCheck_Title')} hideNavBar={true} />
{/* <Scene key='FittingCheck' component={FittingCheckContainer} title={I18n.t('App.UserRegister_Title')} hideNavBar={true} />
<Scene key='FittingCheck' component={FittingCheckContainer} title={I18n.t('App.UserRegister_Title')} hideNavBar={true} /> */}
<Scene key='SizeCheck' component={SizeCheckContainer} title={I18n.t('App.SizeCheck_Title')} hideNavBar={true} />
<Scene key='FittingCheck' component={FittingCheckContainer} title={I18n.t('App.FittingCheck_Title')} hideNavBar={true} />
</Scene>
</Router>
</Provider>
);
}
}
运行时,打开远程调试,可以在Chrome开发工具中看到日志信息

有了日志功能后,可以比较简单的查看到action的type及其他参数,也可以看到每一个action发生前与发生后state(reducers)的变化
react native redux saga增加日志功能的更多相关文章
- react native redux 草稿
Provider > Provider > 使组件层级中的 方法都能够获得 Redux store.正常情况下,你的根组件应该嵌套在 Provider 中才能使用 方法. 如果你真的不想把 ...
- React Native 0.50版本新功能简介
React Native在2017年经历了众多版本的迭代,从接触的0.29版本开始,到前不久发布的0.52版本,React Native作为目前最受欢迎的移动跨平台方案.虽然,目前存在着很多的功能和性 ...
- 14. react 基础 redux 的编写 TodoList 功能
1. 安装 redux 监听工具 ( 需要翻墙 ) 打开 谷歌商店 搜索 redux devtool 安装第一个即可 2. 安装 redux yarn add redux 3. 创建 一个 store ...
- react native redux
redux可以解决, 程序中所有组件的状态统一管理, 从而使我们可以更加动态的,灵活的控制程序 React:数据管理使用props.stateRedux的主要思想:提供一个数据存储中心,可以供外部访问 ...
- [React] 14 - Redux: Redux Saga
Ref: Build Real App with React #14: Redux Saga Ref: 聊一聊 redux 异步流之 redux-saga [入门] Ref: 从redux-thun ...
- 如何为Windows服务增加Log4net和EventLog的日志功能。
一.简介 最近在做一个项目的时候,需要该项目自动启动.自动运行,不需要认为干预.不用说,大家都知道用什么技术,那就是 Windows服务.在以前的Net Framework 平台下,Windows 服 ...
- 【React Native开发】React Native控件之DrawerLayoutAndroid抽屉导航切换组件解说(13)
),请不要反复加群! 欢迎各位大牛,React Native技术爱好者增加交流!同一时候博客左側欢迎微信扫描关注订阅号,移动技术干货,精彩文章技术推送! 该DrawerLayoutAndroid组件封 ...
- 从React Native到微服务,落地一个全栈解决方案
Poplar是一个社交主题的内容社区,但自身并不做社区,旨在提供可快速二次开发的开源基础套件.前端基于React Native与Redux构建,后端由Spring Boot.Dubbo.Zookeep ...
- 【React Native 实战】旋转图片验证码
1.前言蘑菇街用打乱方向的图片作为验证码,既起到了验证码的作用又宣传了图片,今天我们就用React Native来实现这样的功能. 2.属性 Image标签属性resizeMode enum('cov ...
随机推荐
- C#学习目录处理
目录获取和处理: string path = ".";//表明要在当前所在的目录 //先定义目录信息变量 DirectoryInfo dir = new DirectoryInfo ...
- Anaconda创建python(2.7/3.6)的虚拟环境后需要添加ipykernel
今天在工作的过程中遇到这样一个问题:安装完Anaconda利用conda创建了虚拟环境,但是启动jupyter notebook之后却找不到虚拟环境中的python kernel.后来上网找到了解决办 ...
- hdu4085 Peach Blossom Spring
Peach Blossom Spring http://acm.hdu.edu.cn/showproblem.php?pid=4085 Time Limit: 10000/5000 MS (Java/ ...
- Merge Query
1. Oracle: "MERGE into MHGROUP.proj_access m using dual on " + "(PRJ_ID = '" + W ...
- netcore 使用log4net
1.Install Install-Package log4net 2. conifg 創建文件:log4net.config <?xml version="1.0" enc ...
- 【NOIP】提高组2013 积木大赛
[算法]找规律(听说还有写RMQ的www) [题解]ans+=(a[i]-a[i-1]) (i=1...n)(a[i]>a[i-1]) 后面比前面大k,说明要新叠加k个区间来达到所需高度.(看 ...
- Apache的Commons Lang和BeanUtils
1.字符串的空判断 //isEmpty System.out.println(StringUtils.isEmpty(null)); // true System.out.println(S ...
- 初识费用流 模板(spfa+slf优化) 餐巾计划问题
今天学习了最小费用最大流,是网络流算法之一.可以对于一个每条边有一个容量和一个费用(即每单位流的消耗)的图指定一个源点和汇点,求在从源点到汇点的流量最大的前提下的最小费用. 这里讲一种最基础也是最好掌 ...
- python3使用web.py遇到的找不属性的错误解决
今天用pyhon安装完web.py的时候,点击运行还是没错的,但是在网页输入链接就会报错.1.安装我是这样的: pip install web.py 2.运行后错误信息是这样: AttributeEr ...
- SQL语句获取时间的方法
1. 当前系统日期.时间select getdate() 2. dateadd 在向指定日期加上一段时间的基础上,返回新的 datetime 值例如:向日期加上2天select dateadd(day ...