I have a multi-page user registration form in my react/redux app.
When a user clicks "next page," it dispatches a call to update the user's profile in the local redux store (not the server).
When they click "Submit" on the final page, I currently have a click handler along the lines of:
clickHandler: function(formData) {
dispatch(updateProfileInStore(formData);
dispatch(saveProfileToServer());
}
My question is: can I be 100% certain that the Redux store w/ my user profile will update before the second dispatch is called?
I'm worried that in some cases the profile might be written to my database before the last page of form data is added to it.
It's not guaranteed. What you could do is pass saveProfileToServer
the new form data have it update state and send the updated form data to the server.
As per the react documentation
setState() does not immediately mutate this.state but creates a pending state transition. ... There is no guarantee of synchronous operation of calls to setState and calls may be batched for performance gains.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments