我在连接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
动作 最佳答案
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);
关于javascript - 错误:调度不是函数,将injectStripe和mapDispatchToProps连接起来,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/55817261/