✨ Features
-
Add
shouldTouchoption totrigger()([#13671](#13671))setValuealready supportedshouldTouch;trigger()now does too. This allows you to mark field(s) as touched after manual or programmatic validation, such as validate-on-mount or multi-step form navigation, without needing asetValueworkaround:// Mark a single field as touched after validating it await trigger('firstName', { shouldTouch: true }); // Mark every mounted field as touched after validating the whole form await trigger(undefined, { shouldTouch: true });
-
Add
OpaqueTypesregistry for opaque leaf types ([#13676](#13676))Recursive type helpers (
Path,DeepPartial,DeepRequired,FieldErrorsImpl, etc.) previously stopped only atPrimitive | BrowserNativeObject. As a result, rich third-party value types such asDayjsandDecimalcould be recursively traversed member-by-member, potentially causing TypeScript to report "Excessive complexity" diagnostics on large form types.You can now register a type as an opaque leaf via declaration merging:
import type { Dayjs } from 'dayjs'; declare module 'react-hook-form' { interface OpaqueTypes { dayjs: Dayjs; } }
While the registry is empty, types remain identical to the existing behavior. This is purely opt-in.
🐞 Fixes
- Fix inconsistent behavior among
useController().field.onChange()-like APIs. ([#13673](#13673)) - Fix
Controllerunder a null parent submittingundefinedinstead of a value. ([#13675](#13675)) - Fix
ERR_MODULE_NOT_FOUNDwhen resolvingreact-hook-formdue to areact-serverdeclaration in Next.js builds. ([#13682](#13682)) - Fix
useWatchnever reconciling when an Activity subtree is hidden on its first render. ([#13683](#13683)) - Fix
resetFieldnot recomputingisValidfor subscribe-only consumers. ([#13684](#13684)) - Fix
generateWatchOutputignoringdefaultValuefor an array of names. ([#13686](#13686)) - Fix
useFormStatenever reconciling when an Activity subtree is hidden on its first render. ([#13687](#13687))
❤️ Thank You
Thanks to @giaBaoJS, @dfedoryshchev, @Alioth-91, @Masatoshi0227, @modosc, and @bluebill1049 for their contributions! 🎉