我在这里使用Redux和React.js我的handleSubmit方法:
handleSubmit = async (e) => {
e.preventDefault();
await this.props.createCoupon({
value: this.state.value,
expiresDate: new Date(this.state.expiresDate)
});
this.props.fetchCoupons();
}
逻辑上fetchCoupons函数将在createCoupon完成后运行,这可以正常运行,但我会在FETCH_COUPONS_REQUEST
之前和之后进入我的控制台CREATE_COUPON_SUCCESS
,这是怎么回事?
答案 0 :(得分:0)
尝试这样的事情
handleSubmit = async (e) => {
e.preventDefault();
await this.props.createCoupon();
this.props.fetchCoupons();
},
createCoupon(){
value: this.state.value,
expiresDate: new Date(this.state.expiresDate)
}