Skip to content
Discussion options

You must be logged in to vote

You're not doing anything wrong — this is how the context is wired.

FormProvider memoizes the context value, but formState is one of its dependencies:

// src/useFormContext.tsx
const memoizedValue = React.useMemo(() => ({ ...methods, formState }), [/* ..., */ formState, /* ... */])

reset() updates the whole form state (values, dirty, touched, errors, submit count) in one go, so the component that owns useForm re-renders, formState gets a new reference, the context value changes, and every component that calls useFormContext() re-renders. setValue + clearErrors per field only notify the subscribers of that field, which is why your manual loop is quiet.

Options, from least to most change:

1. …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@waxcage
Comment options

Answer selected by waxcage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants