Replies: 3 comments
|
Can you provide a CodeSandbox that demonstrates the problem? |
|
That version jump matters. 7.66 tightened when unmounted / errored fields report values, so bare Pin a fallback so the gap can't produce // before: blows up when reset + validation race
const values = watch();
// after: stays defined through reset/re-register
const values = watch(undefined, { defaultValue: defaultValues });
// or per-field, which is more robust:
const name = watch('name', defaultValues.name);Two other things worth checking since If it still reproduces, the discriminating detail is whether |
|
A quick heads-up before trying the fallback above: For one field, the supported form is: const name = watch('name', defaultValues.name);For the whole form, set I agree with the request for a small reproduction. Keeping the parent's I checked the 7.66.0 watch declarations and verified the supported field-level call with TypeScript. I haven't reproduced your original bug. AI-assisted reply. |
Uh oh!
There was an error while loading. Please reload this page.
Watch returns undefined after validation has triggered and thrown an error.
The component one level above uses reset(), which populates the form with default values.
The problem appeared after updating React Hook Form to version 7.66.0. Previously, the version was 7.54.2, which had no issues.
All reactions