You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The state dispatched in a form action never get committed by React if the form action is pending. The state only changed after the action completed. I'm not sure if this something a bug or a rule must be followed. It seems a bit surprising.
One will only see the value A and continue seeing value A from a minutes after submission, then they will see C. Value B was never printed on the screen.
This seems not really related to the hook but the form action prop. What I want to do is to trigger some async validation before I call the api from the action. Sometimes, the validation resulted a warning that I want the component to enter a "confirmation" state, but I cannot do anything if the action is triggered by the action prop.
The text was updated successfully, but these errors were encountered:
For anyone face the same issue, my workaround is going with useRef, which I park a flag for the state. The outside can then pick it up because isPending will tick a rerender. But this is really dirty, and if you have more than 1 awaiting promises in the the action, this won't work.
In react 19 latest beta (2024.05.25).
The state dispatched in a form action never get committed by React if the form action is pending. The state only changed after the action completed. I'm not sure if this something a bug or a rule must be followed. It seems a bit surprising.
Let's say a naive component like this.
One will only see the value
A
and continue seeing valueA
from a minutes after submission, then they will seeC
. ValueB
was never printed on the screen.This seems not really related to the hook but the form
action
prop. What I want to do is to trigger some async validation before I call the api from theaction
. Sometimes, the validation resulted a warning that I want the component to enter a "confirmation" state, but I cannot do anything if the action is triggered by the action prop.The text was updated successfully, but these errors were encountered: