Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

fix(react-form): Make form.options reactive by adding getter#2044

Draft
swushi wants to merge 1 commit intoTanStack:mainfrom
swushi:fix/form-options-reactivity
Draft

fix(react-form): Make form.options reactive by adding getter#2044
swushi wants to merge 1 commit intoTanStack:mainfrom
swushi:fix/form-options-reactivity

Conversation

@swushi
Copy link

@swushiswushi commentedFeb 17, 2026
edited
Loading

Summary

Fixes an issue whereform.options.defaultValues was not reactive when initializing a form with async data.

Problem

When usinguseForm() with async data:

const{ data}=useAsyncApiData();constform=useForm({defaultValues:data??{foo:''},})// When data loads, `form.state.values` updates correctly,// but form.options.defaultValues is stale (i.e. `{ foo: '' }`)consthasChanges=form.state.values.foo!==form.options.defaultValues.foo;// incorrectly true

Root Cause

Theoptions object was captured in theuseMemo closure and never updated whenformApi.options changed, even thoughformApi.update() was called in the effect lifecycle.

Solution

Added a getter foroptions (similar to the existingstate getter) to ensure the latest options are always returned:

getoptions(){returnformApi.options},

This follows the same pattern as thestate getter, as mentioned in the existing comment:"We must add allgetters fromcore'sFormApi here, as otherwise the spread operator won't catch those"

Related Discussion

https://canary.discord.com/channels/719702312431386674/1471891391348215972

@changeset-bot
Copy link

changeset-botbot commentedFeb 17, 2026
edited
Loading

⚠️ No Changeset found

Latest commit:29a65ed

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go.If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Fixes an issue where form.options.defaultValues was not reactive wheninitializing a form with async data. The options object was capturedin the useMemo closure and never updated when formApi.options changed.Adding a getter for options (similar to the existing state getter)ensures that the latest options are always returned, fixing reactivityissues when comparing current values to defaultValues.
@swushiswushiforce-pushed thefix/form-options-reactivity branch from9fc39cc to29a65edCompareFebruary 17, 2026 15:12
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@swushi

[8]ページ先頭

©2009-2026 Movatter.jp