component 1:
const mapDispatchToProps = (dispatch) => {
return {
currency: (data) => dispatch(currency(data)),
}
}
const mapStateToProps = (state) => {
return ({
changeContent: state.changeContent
}
)
}
handleClick = (e, special) => {
const { changeContent } = this.props;
changeContent({type:"CHANGE",item:e.key})
};
export default connect((state, ownProps) => {
return {
menuList: state.menuList,
userInfor: state.userInfor,
menuKeys: state.menuKey,
language: state.language,
};
}, mapStateToProps,
mapDispatchToProps)(Container);
component 2:
//CommonList
render (){
return (
<div>{this.props.changeContent}</div>
)}
const changeContent =(state)=>({
changeContent:state.changeContent
})
export default connect(changeContent)( Form.create({})(CommonList))
reducer:
const changeContent = (state = [], action) =>{
switch (action.type){
case "CHANGE" :
return ([...state, action.item])
default:
return state
}
}
export default changeContent
if you run it, you will get an error, changeContent is not a function