Skip to content

Changing a field value and submitting the form in a onClick handler #568

Answered by edmundhung
freeman asked this question in Q&A
Discussion options

You must be logged in to vote

It's because React batches all the updates in a callback and the changes you made is not rendered on the UI yet. Wrapping the form.update() call in flushSync should solve your issue.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@freeman
Comment options

Answer selected by freeman
Comment options

You must be logged in to vote
1 reply
@QzCurious
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants