[React 19] When submitting a form action multiple times, requestFormReset throws the TypeError 'Cannot read null property (reading 'queue')'. #31478
+63
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Related Previous Issues: #30041
Related Previous PR: #30365
There was already a PR raised, but I wrote a PR to be more specific and prevent type errors.
When passing an asynchronous function to a
action, if you pass that action again before receiving the response, the stateHook.next value will be null in theensureFormComponentIsStateful
function running inside the requestFormReset function, resulting in a type error. To prevent this problem, I modified theensureFormComponentIsStateful
function to maintain the current statefull state if thestateHook.next
value is null.Test Code
Test Step
(usually after 2-3 seconds, just before the response comes)
How did you test this change?
yarn test
.If there is anything wrong, please tell me.