I'm using Redux with React.js here my handleSubmit method:
handleSubmit = async (e) => {
e.preventDefault();
await this.props.createCoupon({
value: this.state.value,
expiresDate: new Date(this.state.expiresDate)
});
this.props.fetchCoupons();
}
Logically fetchCoupons function will run after createCoupon finish and this works but im getting in my console FETCH_COUPONS_REQUEST
before and after CREATE_COUPON_SUCCESS
, how is that?
try something like this
handleSubmit = async (e) => {
e.preventDefault();
await this.props.createCoupon();
this.props.fetchCoupons();
},
createCoupon(){
value: this.state.value,
expiresDate: new Date(this.state.expiresDate)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.