1.写法

import { connect } from 'redux';
import { loading, asyncRequset } from '../../actions/common'; export default connect(({ counter, homePage, common }) => ({
/**
* 取到3个reducer的值
* 通过 homePage 可以获取到绑定在该 reducer 上的所有数据
* 例如:const { listData } = this.props.homePage
*/
counter, homePage, common
}), (dispatch) => ({
getAsyncRequset(text, data, url) { // 通过 this.props.getAsyncRequset 调用
dispatch(asyncRequset(text, data, url))
},
getLoading() { // 通过 this.props.getLoading 调用
dispatch(loading())
}
}))(MyIndex)

.

connect(mapStateToProps,mapDispatchToProps) 的写法的更多相关文章

  1. react依赖注入之mapStateToProps&&mapDispatchToProps

    今天看前辈写的代码,看到mapStateToProps&&mapDispatchToProps处,不明白,于是又是各种找资料,在CSDN博客中发现一篇好文,摘抄到此,方便自己阅读! 原 ...

  2. react+redux教程(一)connect、applyMiddleware、thunk、webpackHotMiddleware

    今天,我们通过解读官方示例代码(counter)的方式来学习react+redux. 例子 这个例子是官方的例子,计数器程序.前两个按钮是加减,第三个是如果当前数字是奇数则加一,第四个按钮是异步加一( ...

  3. rematch:当你受不了redux繁琐写法的时候,是时候了解一波rematch了

    前言: 前段时间学习完react后,刚好就接到公司一个react项目的迭代,顺便巩固一下前段时间的学习成果.项目使用的是redux+react-router,将所有的数据都放在redux中,异步处理数 ...

  4. Redux和React-Redux的实现(二):Provider组件和connect的实现

    接着上一篇讲,上一篇我们实现了自己的Redux和介绍了React的context以及Provider的原理. 1. Provider组件的实现 Provider组件主要有以下下两个作用 在整个应用上包 ...

  5. React系列——react-redux之connect方法解析

      connect简介 前方高能预警,有耐心才能看完文章!! react-redux仅有2个API,Provider和connect,Provider提供的是一个顶层容器的作用,实现store的上下文 ...

  6. [Redux] Accessing Dispatch and State with Redux -- connect

    If you have props and actions, you want one component to access those props and actions, one solutio ...

  7. [Redux] Using mapDispatchToProps() Shorthand Notation

    We will learn how to avoid the boilerplate code in mapDispatchToProps() for the common case where ac ...

  8. [Redux] Generating Containers with connect() from React Redux (VisibleTodoList)

    Learn how to use the that comes with React Redux instead of the hand-rolled implementation from the ...

  9. React-redux框架之connect()与Provider组件 用法讲解

    react-redux 在react-redux 框架中,给我提供了两个常用的API来配合Redux框架的使用,其实在我们的实际项目开发中,我们完全可以不用react-redux框架,但是如果使用此框 ...

随机推荐

  1. uva 10648(简单dp)

    Recently one of my friend Tarik became a member of the food committee of an ACM regional competition ...

  2. mtk预装apk 方案公司内置预装apk

    mtk预装apk 方案公司内置预装apk 韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha == MTK 预知第三方的APK 流程_yua ...

  3. xUtils 中的 BitmapUtils

    韩梦飞沙  韩亚飞  313134555@qq.com  yue31313  han_meng_fei_sha xUtils框架,包括BitmapUtils.DbUtils.ViewUtils和Htt ...

  4. 【分块】【暴力】XVII Open Cup named after E.V. Pankratiev Grand Prix of Moscow Workshops, Sunday, April 23, 2017 Problem I. Rage Minimum Query

    1000w的数组,一开始都是2^31-1,然后经过5*10^7次随机位置的随机修改,问你每次的全局最小值. 有效的随机修改的期望次数很少,只有当修改到的位置恰好是当前最小值的位置时才需要扫一下更新最小 ...

  5. 【置换群】poj3270 Cow Sorting

    并不应该叫置换群……只是用到了置换而已,并没有群. 题解看这个吧,我就不写了:http://www.cnblogs.com/kuangbin/archive/2012/09/03/2669013.ht ...

  6. 企鹅----sap+裂点

    企鹅 题目描述 在靠近南极的某处,一些企鹅站在许多漂浮的冰块上.由于企鹅是群居动物,所以它们想要聚集到一起,在同一个冰块上.企鹅们不想把自己的身体弄湿,所以它们在冰块之间跳跃,但是它们的跳跃距离,有一 ...

  7. idea小问题解决方法系列

    1)有些java文件上显示“红色小j”,如图所示 ,意思是“不可编译”,原因是Module未导入或者没有标记Module下"Sources"一栏src文件夹为Sources.(ht ...

  8. Xcode9出现错误safe area layout guide before ios 9 真正解决办法

    网上很多解决办法瞎扯淡,以讹传讹之势愈演愈烈. 正解是选中控制器,右边面板的Builds for 选择iOS9.0 and Later,如下图红框广为流传的错解是不勾选Use Safe Area La ...

  9. Failed to Attach to Process ID Xcode 解决办法

    方法1. go to the Product menu and find the Edit Scheme menu there. While in Edit Scheme window, select ...

  10. Integer引用类型问题

    public class TestMain { public static void main(String[] args) { Integer integer = 2; go(2); System. ...