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#] 类型学习笔记三:自定义值类型
既前两篇之后,这一篇我们讨论通过struct 关键字自定义值类型. 在第一篇已经讨论过值类型的优势,节省空间,不会触发Gargage Collection等等. 在对性能要求比较高的场景下,通过str ...
- rocketmq单机搭建
RocketMQ 是alibaba开源的消息队列. 本文使用的是开源版本v3.18 系统: centos6.x最小化安装 需要用到的软件包: jdk-7u67-linux-x64.tar.gz ali ...
- 查看自己电脑外网IP
连着wifi,在CMD窗口中显示的无线局域网适配器IP很有可能是内网IP.此时可以通过下面方法查看自己的电脑外网IP. 1.前提条件可以上外网: 2.上外网百度,输入IP,进行搜索. 3.查看结果即可 ...
- [LeetCode] 1. Two Sum ☆
Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...
- 数学:拓展BSGS
当C不是素数的时候,之前介绍的BSGS就行不通了,需要用到拓展BSGS算法 方法转自https://blog.csdn.net/zzkksunboy/article/details/73162229 ...
- 动态规划:区间DP与环形DP
区间型动态规划的典型例题是石子归并,同时使用记忆化搜索实现区间动归是一种比较容易实现的方式,避免了循环数组实现的时候一些边界的判断 n堆石子排列成一条线,我们可以将相邻的两堆石子进行合并,合并之后需要 ...
- web开发中防止SQL注入
一.SQL注入简介 SQL注入是比较常见的网络攻击方式之一,它不是利用操作系统的BUG来实现攻击,而是针对程序员编写时的疏忽,通过SQL语句,实现无账号登录,甚至篡改数据库. 二.SQL注入攻击的总体 ...
- 【BZOJ】1731: [Usaco2005 dec]Layout 排队布局
[题意]给定按编号顺序站成一排的牛,给定一些约束条件如两牛距离不小于或不大于某个值,求1和n的最大距离.无解输出-1,无穷解输出-2. [算法]差分约束+最短路 [题解]图中有三个约束条件,依次分析: ...
- Codeforces Round #483 (Div. 2) [Thanks, Botan Investments and Victor Shaburov!]
题目链接:http://codeforces.com/contest/984 A. Game time limit per test:2 seconds memory limit per test:5 ...
- DesignPattern
目录