当我点击按钮时出现错误
未捕获的TypeError:_this2.props.dispatch不是函数
@
请帮帮我
答案 0 :(得分:1)
const mapDispatchToProps = (dispatch) => {
return {
activateGeod: bindActionCreators(activateGeod, dispatch),
closeGeod: bindActionCreators(closeGeod, dispatch),
}
};
应该是
const mapDispatchToProps = (dispatch) => ({
activateGeod: bindActionCreators(activateGeod, dispatch),
closeGeod: bindActionCreators(closeGeod, dispatch),
logout: () => dispatch(logout()),
});
然后,您只需在组件中调用this.props.logout()
而不是dispatch(logout())