Repository navigation
fix(react): derive form state from submission outcomes and guard concurrent submits - #738
Open
kotarotaniguchi0523 wants to merge 1 commit into
Open
kotarotaniguchi0523 wants to merge 1 commit into
kotarotaniguchi0523 wants to merge 1 commit into
Conversation
…urrent submits - Represent useForm submission results with a discriminated union (SubmissionOutcome) owned by useActionState, deriving errors, error, hasChanges, wasSuccessful, and recentlySuccessful without redundant state or refs. - Snapshot form data and dispatchData at dispatch time so synchronous setData() calls, in-flight edits (including under resetOnSuccess), and queued React actions preserve their submitted payload and post-success baseline. - Scope callbackOutcomeRef across async onError and synchronous onSuccess so reset(), setError(), clearErrors(), and clearError() inside callbacks operate on the incoming outcome without leaking uncommitted defaults to external UI interactions during await. - Return a fresh idle outcome when a submission aborts so previous validation errors or success states do not revive. - Represent useIslandForm state with a single IslandOutcome union and requestId so the latest started submission owns pending and UI state across completion orders. - Check 429 retryAt deadlines directly in <Form> onSubmit instead of mounting timer state and effects.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
useForm()status (errors,error,hasChanges,wasSuccessful,recentlySuccessful) from theuseActionStateoutcome instead of syncing separate states and refs acrossawait.resetOnSuccess: true) keep their submitted payload and baseline.reset(),setError(),clearErrors(), andclearError()insideonSuccess/onErrorapply to the new outcome without exposing uncommitted defaults duringawait.useIslandForm()with a request ID so the latest submission ownspendingand UI state across out-of-order completions.retryAtdeadlines directly in<Form>onSubmitinstead of mounting a timer effect.Test plan
vp fmt --check&vp lintvp run build&vp run check:sdkvp test run packages/react/test/unit