业务:点击按钮实现数量的增加
创建react项目
$ npx create-react-app react-immutable
进入项目,安装插件
$ yarn add redux immutable react-redux redux-immutable
在src目录下新建components目录,在components目录下新建Button,Content两个组件
import React, { Component } from 'react'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'
import actionCreators from '../store/count/actionCreators';
class Button extends Component{
render(){
return(
<div>
<button onClick={this.props.increment}>+</button>
</div>
)
}
}
export default connect(
state => ({
count: state.getIn(['count'])
}),
dispatch => bindActionCreators(actionCreators