我在连接mapStateToProps
时遇到麻烦,因此该操作被适当地调用:
const mapDispatchToProps = (dispatch) => {
return {
createPayment: (token, email) => dispatch(createPaymentForToken(token, email)),
};
};
const injectedCheckoutForm = injectStripe(CheckoutForm);
export default connect(mapDispatchToProps)(injectedCheckoutForm);
当我致电this.props.createPayment(token, email)
时,出现以下错误:
index.js:130未捕获(承诺)TypeError:调度不是函数
编辑:我的动作似乎正在被调用,但我的传奇人物却没有听CREATE_PAYMENT
动作
答案 0 :(得分:2)
connect
的第一个参数为mapStateToProps
,第二个参数为mapDispatchToProps
。而是尝试connect(null, mapDispatchToProps)
。
const mapDispatchToProps = (dispatch) => {
return {
createPayment: (token, email) => dispatch(createPaymentForToken(token, email)),
};
};
const injectedCheckoutForm = injectStripe(CheckoutForm);
export default connect(null, mapDispatchToProps)(injectedCheckoutForm);