Skip to content

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Sep 8, 2025

Problem

The way useApplyDefaultValues and ArrayInput subscribe to the form context to check for dirty or error state force a full rerendering of all fields in a field array on each change. This is very harmful for performance.

Solution

react-hook-form v7.62.0 introduces a way to subscribe to form changes without triggering a rerender. We can therefore manage the dirty and error states by hand to avoid the rerender.

How to test

Open the console, change the value of one field. Only this field should rerender

Open the React profiler, update one value in the array input, check out the output: no rendering should rerender all fields.

## Problem

The way useApplyDefaultValues and ArrayInput subscribe to the form context to check for dirty or error state force a full rerendering of all fields in a field array on each change. This is very harmful for performance.

## Solution

react-hook-form v7.62.0 introduces a way to subscribe to form changes without triggering a rerender. We can therefore manage the dirty and error states by hand to avoid the rerender.
@djhi
Copy link
Collaborator

djhi commented Sep 9, 2025

For now, we're stuck until react-hook-form/react-hook-form#12815 is solved

@fzaninotto fzaninotto changed the title Speed up ArrayInput [blocked] Speed up ArrayInput Sep 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WIP Work In Progress
Development

Successfully merging this pull request may close these issues.

2 participants