Skip to content

fix(react-hook-form): replace custom layout effect sync with native reset - #7492

Open
deepshekhardas wants to merge 2 commits into
refinedev:mainfrom
deepshekhardas:fix/useFieldArray-empty-revisit
Open

fix(react-hook-form): replace custom layout effect sync with native reset#7492
deepshekhardas wants to merge 2 commits into
refinedev:mainfrom
deepshekhardas:fix/useFieldArray-empty-revisit

Conversation

@deepshekhardas

Copy link
Copy Markdown

What is the current behavior?

During SPA navigation, useFieldArray instances wrapped within components conditional on formLoading fail to retain values upon form remounting. This occurs because the internal microtask-deferred applyValuesToFields executes and checks getRegisteredFields() before the dynamically rendering inputs finish their mount-level registration lifecycle with React Hook Form.

What is the new behavior?

Replaced the custom microtask applyValuesToFields on initial data load with React Hook Form's native reset(data, { keepDirtyValues: true }). This natively handles delayed field hydration irrespective of active DOM input registration states, ensuring complete value restoration when revisiting the edit view.

fixes #7401

@changeset-bot

changeset-bot Bot commented Jul 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: fe540b7

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

- fix(cli): replace temp with native fs.mkdtempSync (refinedev#7388)
- fix(react-hook-form): useFieldArray reset on initial data load (refinedev#7402)
- feat(core): add ns namespace option to useTranslation/useTranslate (refinedev#7386)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] useFieldArray fields empty on second visit when using useForm

1 participant