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. sql 预编译 in

    sql : "select * from json where id in (:paramName)"; 在使用Hibernate时,sql in的预编译语句为query.setP ...

  2. [Agc008F]Black Radius

    [AGC008F] Black Radius Description 给你一棵有N个节点的树,节点编号为1到N,所有边的长度都为1 "全"对某些节点情有独钟,这些他喜欢的节点的信息 ...

  3. 【DFS】【打表】Lattice Animals

    [ZOJ2669]Lattice Animals Time Limit: 5 Seconds      Memory Limit: 32768 KB Lattice animal is a set o ...

  4. 【贪心】hdu6180 Schedule

    题意:给你n个任务的开始时间和结束时间,一个机器同时最多执行一个任务,问你最少要几个机器.保证机器最少的前提下,问你每个机器的开动时间(最后一次关闭-第一次开启)之和最少是多少. 把这些线段画在数轴上 ...

  5. MySort的后续学习

    本周老师在课上布置的一个MySort的任务 在结合了老师的模板后,我在课上写出了如下代码: import java.util.*; public class MySort { public stati ...

  6. [转]Java中fina以及static的意义

    一.final        根据程序上下文环境,Java关键字final有“这是无法改变的”或者“终态的”含义,它可以修饰非抽象类.非抽象类成员方法和变量.你可能出于两种理解而需要阻止改变:设计或效 ...

  7. Mysql双主实战

    参考:http://dev.mysql.com/doc/refman/5.1/en/replication-options-slave.htmlhttp://blog.chinaunix.net/ui ...

  8. 使用MailKit收发邮件

    .Net BCL库中对于邮件的支持只有SmtpClient一个,它只能进行简单的邮件的发送操作,并且不支持POP3和SMTP,无法接收邮件,用起来有诸多不便. 今天看到园子里有文章(使用 MimeKi ...

  9. win7与Ubuntu 13.04双系统修改启动项顺序

    在在win7下安装了Ubuntu 13.04后,在grub中,win7启动想是最后一个,为了把win7设置为默认启动项,需要更改grub设置.google了半天,发现更改/etc /default/g ...

  10. C# 中的.pdb/ .vshost.exe/ .vshost.exe.manifest文件

    转自 C# 中的.pdb/ .vshost.exe/ .vshost.exe.manifest文件讨论 pdb文件: 英文全称:Program Database File 中文全称:程序数据库 文件 ...