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 ...
随机推荐
- [LeetCode] string整体做hash key,窗口思想复杂度O(n)。附来自LeetCode的4例题(标题有字数限制,写不下所有例题题目 T.T)
引言 在字符串类型的题目中,常常在解题的时候涉及到大量的字符串的两两比较,比如要统计某一个字符串出现的次数.如果每次比较都通过挨个字符比较的方式,那么毫无疑问是非常占用时间的,因此在一些情况下,我们可 ...
- 51Nod 1083 矩阵取数问题 | 动态规划
#include "bits/stdc++.h" using namespace std; #define LL long long #define INF 0x3f3f3f3f3 ...
- HDU1164
//HDU 1164 //输入一个数(1<x<=65535) 转化为素数的乘积() #include "iostream" #include "cstdio& ...
- python初步学习-pycharm使用 (二)
pycharm调试模式 假设我们的程序在运行过程中命中了一个错误,那我们如何定位错误发生的位置?这就需要进行调试. 在Pycharm中我们可以在其中直接对程序进行调试,唯一需要做的准备工作就是在程序必 ...
- 8.0docker的客户端和守护进程
C/S 链接的方式 unix:///var/run/docker.sock 默认的 tcp://host:port fd://socketfd 在linux上进行socket 模拟 nc -U /va ...
- 查看服务器是否被DDOS攻击的方法
伴随着现代互联网络快速发展,更加容易出现被攻击.尤其是ddos攻击已经不在是大网站需要关心的事情了.不少中小型企业,也在遭受ddos攻击.站长对ddos攻击不了解,所以网站被ddos攻击的时候,都不会 ...
- Vue组件-组件的注册
注册组件 全局组件 注册组件就是利用Vue.component()方法,先传入一个自定义组件的名字,然后传入这个组件的配置. Vue.component('my-component', { templ ...
- Linux Platform驱动模型(二) _驱动方法【转】
转自:http://www.cnblogs.com/xiaojiang1025/archive/2017/02/06/6367910.html 在Linux设备树语法详解和Linux Platform ...
- mips64高精度时钟引起ktime_get时间不准,导致饿狗故障原因分析【转】
转自:http://blog.csdn.net/chenyu105/article/details/7720162 重点关注关中断的情况.临时做了一个版本,在CPU 0上监控所有非0 CPU的时钟中断 ...
- FIS3 大白话【一】
1.fis3可以用fis.set进行一些全局的配置,包括忽略文件.文件后缀处理类型.源码过滤等等,用fis3.get可以得到配置信息,详见: http://fis.baidu.com/fis3/doc ...