1.在首页引入 store 而且注册了两个中间件
import React, {Component} from 'react';
//一步一步实现手写flux到使用插件编写
import Input1 from './Input1'
import Input2 from './Input2'
import Store from './store'
import Dispatcher from './dispatcher'
// import {connect} from 'react-redux';
const store = new Store();
class ReduxIndex extends Component {
constructor(props) {
super();
//调用这个方法其实就是就函数以参数的形式传到dispatcher中存在数组中等待用户执行action的时候调用
Dispatcher.use((action, next) => {
setTimeout(function () {
console.log('我是中间件1' + action.type);
next();
}, 2000);
});
Dispatcher.use((action, next) => {
console.log('我是中间件2' + action.type);
next()
});
}
render() {
return (
<div>
input1:<Input1 type="up" st