# Changelog ## [7.86.0] - 2026-08-22 ### Added - Type-safe `getErrors` method ### Performance - Improve `createFormControl` - Improve clone object check - Avoid cloning values in `unregister` without subscribers ### Fixed - Field array update leaving stale errors and touched state at the updated index - `flatten` discarding `File` and `Blob` values instead of treating them as leaf nodes - `validateField` not passing the field error to `setCustomValidity` when `criteriaMode` is `all` - `hasValidation` treating falsy but valid values (`min: 0`, `max: 0`, `minLength: 0`, `maxLength: 0`, `required: ''`) as no validation - `setValue` targeting a nested leaf not notifying a `Controller` registered on a field array item root - `setValues` not updating fields registered under an object or array value - `useWatch` returning a stale value on name change when the new value is `null` - `unregister` inverting `keepDirty` when broadcasting `isDirty` ## [7.85.0] - 2026-08-08 ### Added - Support `` ### Fixed - `getFieldState` error resolution from a field path - `useWatch` discarding `useForm({ defaultValues })` in favor of its own `defaultValue` before the form mounts - `setValue` emitting a duplicate `values` state notification for fields without a native input ref - Stale render re-creating a field array path vacated by an array action - `useFieldArray` root-level error (`errors.name.root`) being lost on `append`/`prepend`/`insert`/`remove` - `min`/`max` validation being skipped for `valueAsDate` fields ## [7.84.0] - 2026-08-01 ### Improvements - `handleSubmit` returns the typed result of the `onValid` callback instead of discarding it - `
` supports a function-based `action` (Server Action style) in addition to URL-string actions - Improve performance and reduce bundle size ### Fixed - `reset()` with `resetOptions.keepDirtyValues` freezing clean sibling fields in a nested object when another field in that object is dirty - Restore missing `FieldArray` and `FormState` type exports - `setValues` not notifying `useFieldArray` subscribers, leaving rendered fields stale ## [7.83.0] - 2026-07-25 ### Improvements - Enhance `getEventValue` to handle file inputs - Improve TypeScript performance with a hard cap at 10 levels of recursive type depth ### Fixed - Clear internal errors state on argument-less `clearErrors()` - Preserve `dirtyFields` reference stability - Old checkbox/radio elements polluting internal field state - `useController` not re-subscribing `onChange`/`onBlur` when `control` changes - Allow validation messages to be defined even if their related value is `undefined` ## [7.82.0] - 2026-07-18 ### Added - Opt-in `delayError` option for `setValue` to delay validation error updates ### Fixed - Expose `resetDefaultValues` through form context - `setValue` with `shouldDirty` not updating dirty state correctly when the form is disabled - Preserve `dirtyFields` boolean values for registered array fields - Restore `FieldArray` component export ### Performance - Improve `getDirtyFields` performance, especially for larger forms and deeply nested values ## [7.81.0] - 2026-07-05 ### Added - `FieldArray` component built on `useFieldArray` for controlled field-array rendering ### Fixed - `clearErrors` changing the `name` value from `form.subscribe` - `reset` triggering `subscribe` with the latest name instead of `undefined` - `setValues` leaving stale elements behind when shrinking a field array - `flatten` preserving `Date` values as leaf nodes - `useFieldArray` min length validation error changing location in the `errors` object - `useController` not reflecting a cleared parent object in controlled fields ### Security - Harden `unset()` against prototype-path traversal (`__proto__` / `constructor` / `prototype`), matching the existing `set()` guard ### Performance - Improve re-render with `useFieldArray` reset ## [7.80.0] - 2026-06-20 ### Added - `disabled` prop support for individual fields within `useFieldArray` ### Fixed - `deepEqual` incorrectly treating empty array `[]` and empty plain object `{}` as equal ### Performance - Improve `onChange`, `setValid`, dirty checking, `setValue`, and `setValues` performance ## [7.79.0] - 2026-06-13 ### Added - `disabled` option to `useFieldArray` ### Fixed - `Controller` `onChange` promise return type - `deepEqual` false positives with shared object references - `shouldUseNativeValidation` behavior for radio groups - `createFormControl` stability with fast refresh in dev mode - `StrictMode` value preservation during remount - `formState.errors` reactivity with React compiler ## [7.78.0] - 2026-06-08 ### Fixed - Recover `Controller` fields after `reset` without rerender (RN issue #13455) - `useFormState().isDirty` race with async resolver in `onChange` mode - Use reactive `values` prop over `defaultValues` when `shouldUnregister` is true - `deepEqual` for empty non-plain objects ### Types - Update `dirtyFields` typing for field arrays with undefined entries ## [7.77.0] - 2026-05-31 ### Added - `resetDefaultValues` API ### Fixed - Stale `isDirty` in `subscribe` payload after `reset(..., { keepValues: true })` - Preserve values with `shouldUnregister` - Inconsistent `reset({})` behavior requiring double-call to take effect - `FieldArray` errors overriding nested fields ### Security - Harden `get()` against prototype-path traversal (`__proto__` / `constructor` / `prototype`) ### Performance - Bundle size reduction ## [7.76.1] - 2026-05-23 ### Fixed - Revert notify all matching field-array roots on nested `setValue` updates - Revert treat `NaN` as empty when `valueAsNumber` is `true` in `validateField` - `setValues` pass `options` parameter through to enable validation - `setValues` emit whole-form change without stale `name`/`type` ### Performance - `setValues` skip redundant per-field deep clones - `setValues` thread `skipClone` through `setFieldValue` ## [7.76.0] - 2026-05-16 ### Added - Improve `isDirty` sync with `dirtyFields` state ### Fixed - Preserve `formState.defaultValues` when `useFieldArray` and `watch` are used together - Preserve nested resolver field-array errors in `trigger()` - Notify all matching field-array roots on nested `setValue` updates - `useFieldArray` `remove` leaves array with empty object when using `values` prop - Preserve reset values for conditionally mounted `Controller` fields with `shouldUnregister` - Propagate `setValues` updates to mounted `Controller` fields - Native validation tooltip suppression caused by duplicate submit-error focus - `append({ obj: null })` silently replaced by `defaultValues` after `remove()` - Errors state when using form-level validation - `isValidating` reactivity when `validatingFields` is not subscribed ## [7.75.0] - 2026-05-02 ### Added - Improve `getDirtyFields` to prune empty fields - TypeScript 6.0 support ### Fixed - Include `setValues` in `FormProvider` context value - Preserve watch updates on field array unmount - Prevent `useWatch` re-render when unrelated field validation occurs - Recompute `isDirty` after re-registering a previously unregistered field ## [7.74.0] - 2026-04-26 ### Added - `setValues` API ### Fixed - Preserve previous field value when `useController` name changes - Handle null parent when unregistering nested field - Treat `NaN` as empty when `valueAsNumber` is `true` in `validateField` ## [7.73.1] - 2026-04-21 ### Fixed - Reverted `setValues` that was accidentally included in patch; fix build to exclude test files ## [7.73.0] - 2026-04-18 ### Added - Improve `subscribe` API performance ### Performance - Memoize submit handler - Improve `deepEqual` performance ### Fixed - Safely access `field._f` during register - Improve `fieldState` errors when resolver uses dot-notation string keys - Update state correctly in watch callback with `Controller`, `trigger`, and `reset` - Skip field array validation when mode is `onBlur` - `isDirty` remains false after deleting an item with `shouldDirty: true` - Handle nested field when parent `defaultValue` is null - Skip re-render in `setValue` when value is unchanged ## [7.72.1] - 2026-04-03 ### Fixed - Prevent `setValue` with `shouldDirty` from polluting unrelated dirty fields - Memoize control in `HookFormControlContext` to prevent render conflicts - `isNameInFieldArray` should check all ancestor paths for nested field arrays - `formState.isValid` incorrect on `Controller` re-mount ## [7.72.0] - 2026-03-22 ### Added - Built-in form-level `validate` option - Subscribe `formState` to track submit state ### Fixed - Checkbox form validation ignored with native validation - Prevent `useFieldArray` from marking unrelated fields as dirty ## [7.71.2] - 2026-02-21 ### Fixed - `clearErrors` emit name signal for targeted field updates - Use `DeepPartialSkipArrayKey` for `WatchObserver` value parameter ## [7.71.1] - 2026-01-14 ### Fixed - Issue with `booleans_as_integers` value handling ## [7.71.0] - 2026-01-11 ### Changed - Separate control context to prevent unnecessary rerenders - Memoize `FormProvider` context value to prevent unnecessary rerenders ### Fixed - Update `isValid` when field `disabled` state changes ## [7.70.0] - 2026-01-04 ### Fixed - Prevent field array ghost elements with `keepDirtyValues` - Improve `watch` return types - Improve invalid date handling in `deepEqual` and validation - Handle branded types correctly in `DeepPartial` - Fix native validation focus issue - Prevent duplicate subscription trigger in `setValue` ## [7.69.0] - 2025-12-20 ### Added - Align `` API with `useWatch` ### Fixed - Security: CVE-2025-67779, CVE-2025-55184, CVE-2025-55183, CVE-2025-55182 - Preserve `isValid` state when `keepIsValid` option is used - Ensure `createFormControl.subscribe` subscription listens only to subscribed changes - Batch `isValidating` state updates with validation result - Resolve race condition between `setError` and `setFocus` ## [7.68.0] - 2025-12-04 ### Added - `` component ### Fixed - Clear validation errors synchronously in `reset()` to fix Next.js 16 Server Actions issue ## [7.67.0] - 2025-11-29 ### Added - `exact` option for `useController` props ### Fixed - Allow `undefined` value with async `defaultValues` in `Controller` - Correct `PathValueImpl` type inference ## [7.66.1] - 2025-11-18 ### Performance - Reduce redundant property access in `getDirtyFields` ### Fixed - Skip `setValid()` during batch array updates - Recompute `isValid` after `reset` when values update asynchronously - Handle NaN comparison correctly using `Object.is` in `deepEqual` ## [7.66.0] - 2025-11-01 ### Added - `useWatch` and `useController` now react to `name` prop changes ### Fixed - `watch()` returning `undefined` immediately after `reset()` - Correct render function parameter typing for `` component ## [7.65.0] - 2025-10-11 ### Added - `` component ### Fixed - Respect parent-provided `useFieldArray` rules - `getDirtyFields` submit fields with `null` values when using `useForm` ## [7.64.0] - 2025-10-04 ### Added - Support optional array fields in `PathValueImpl` type ### Fixed - Preserve `Controller`'s `defaultValue` with `shouldUnregister` prop ## [7.63.0] - 2025-09-20 ### Added - Improve get dirty fields logic - Extra form values accessible via `formState` ### Fixed - Only execute trigger function when deps has a valid array - Unregister previous field when switching conditional Controllers - Use field name to update `isValidating` fields ## [7.62.0] - 2025-08-02 ### Fixed - Sync two `defaultValues` after `reset` with new `defaultValues` - Field name type conflict in nested `FieldErrors` - Prevent `onBlur` for `readOnly` fields - Do not override prototype of `data` in `cloneObject` ## [7.61.1] - 2025-07-24 ### Fixed - Reverted `watch` return type change based on `defaultValue` (caused regressions) ## [7.61.0] - 2025-07-24 ### Added - `compute` prop for `useWatch` subscription ### Fixed - Subscribe with latest `defaultValues` - Trigger watch callbacks only in response to value changes - Track name with `setValue` subscription callbacks - Handle explicit `"multipart/form-data"` encType in `` component - Remove React wildcard import to resolve ESM build issues ## [7.60.0] - 2025-07-05 ### Added - `reset` with `keepFieldsRef` option to keep fields reference ### Fixed - Remove `Set` from clone object ## [7.59.0] - 2025-06-28 ### Added - Support deep equality checking with circular references ### Fixed - Issue with `formData` reference clone - Issue with `undefined` value for submit data - `useWatch` object variable param handling ## [7.58.0] - 2025-06-15 ### Added - `FieldArrayPathByValue` type - Use `stringToPath` to prevent errors at field names containing quotes ### Fixed - Incorrect `formControl` return from `useForm` - Initial `useFieldArray` fields population ## [7.57.0] - 2025-06-02 ### Added - Focus form field for errors supplied via `errors` prop - Export `UseFormResetFieldOptions` type for `resetField` API - Root errors count in schema error lookup ### Fixed - Type info for callback args in `subscribe` - Proper types for `form.subscribe` - `useController` focus function runtime issue - `setValue` skips values not in own properties (prevents infinite call stack with self-referencing proto) - Checkbox duplication handling in `useFieldArray` - `mode` and `reValidateMode` reactivity - Default value being overwritten by `values` prop regression ## [7.56.0] - 2025-04-20 ### Added - Reactive `mode` and `reValidateMode` support - `isReady` state for subscription ### Fixed - Regression on move/swap in `useFieldArray` input update - Use `useIsomorphicLayoutEffect` to address SSR warning ## [7.55.0] - 2025-03-29 ### Added - `createFormControl` and `subscribe` function - Infer resolver output types - Allow components with `useController` hook to be memoized - Track disabled fields and only omit data on submit - Stable reference for `useWatch` `defaultValue` - `handleSubmit` with native events support ### Fixed - Type inference for `useFormContext` - `values` and `defaultValues` work correctly with `createFormControl` and `useMemo` - Prevent infinite render with condition check - Valid state update with `onBlur` mode - `disabled` field value not returned as `undefined` in resolver - `revalidateMode` issue with `useFieldArray` validation - `useController` unregister issue with strict mode - `setError` in `useEffect` not working inside `FormProvider` context - `useController` return props reference stability ## [7.54.0] - 2024-12-09 ### Changed - `useForm` return methods will be memorized based `formState` update ## [7.53.0] - 2024-8-31 ### Added - add support for `onBlur` with formState `isValid` ### Changed - `validateFields` will only trigger re-render for async validation ## [7.51.0] - 2024-3-2 ### Added - added 'validateFields' to formState ```tsx const { formState: { validateFields }, } = useForm(); ``` ## [7.49.0] - 2023-12-10 ### Added - add reactive `errors` prop at `useForm` ```tsx useForm({ errors, // Server errors }); ``` ## [7.48.0] - 2023-11-05 ### Added - added new `disabled` prop for `useForm` to disable the entire form ``` const App = () => { const [disabled, setDisabled] = useState(false); const { handleSubmit } = useForm({ disabled }); return ( { setDisabled(true); await sleep(100); setDisabled(false); })} / > ); } ``` ## [7.47.0] - 2023-10-02 ### Added - `reset` api with `keepIsSubmitSuccessful` option, keep successfully submitted form state. ```tsx { reset(formValues, { keepIsSubmitSuccessful: true, }); }} /> ``` ## [7.46.0] - 2023-09-03 ### Added - Controller `disabled` prop ```jsx const [disabled, setDisabled] = useState(false); useController({ disabled, }); ``` - Trigger passed names to construct resolver options - Add `exact` option for array name in `useWatch` ### Changed - Update `isDirty` when setting `disabled` in `register` ## Fixed - Prevent `reset` argument mutation ## [7.45.0] - 2023-06-20 ### Changed - Controller with type check on `onChange` ```diff - onChange: (...event: any[]) => void; + onChange: (event: ChangeEvent | FieldPathValue) => void; ``` - Include missing generic for `useFormContext` ```diff - export const useFormContext: () => UseFormReturn; + export const useFormContext: () => UseFormReturn; ``` ## [7.44.0] - 2023-06-14 ### Added - New `` component ```tsx // Send post request with formData { alert("Great"); }} /> // Send post request with json form data {errors.root?.server.type === 500 && 'Error message'} {errors.root?.server.type === 400 && 'Error message'} // Send post request with formData with fetch
{ await fetch("api", { method: "post", body: formData, }); }} /> ``` - support `TransformedValues` with `useFormContext` `useFormContext()` - added `TTransformedValues` to `FormProvider` FormProviderProps ## [7.43.0] - 2023-01-30 ### Added - support global error type ```tsx const onSubmit = async () => { setError('root.serverError', { type: response.statusCode, }); }; const onClick = () => { setError('root.random', { type: 'random', }); }; return ( <> {errors.root.serverError.type === 400 &&

server response message

}

{errors.root?.random?.message}

); ``` ## [7.42.0] - 2023-01-13 ### Added - build in validation `validate` support second argument for form values ```tsx // Making exported validate function isolated for validation export function validateNumber(_: number, formValus: FormValues) { return formValus.number1 + formValus.number2 === 3; } ; ``` ### Changed - `handleSubmit` no longer catch `onSubmit` callback error - Remove deprecated for `fieldState.invalid` ## [7.41.0] - 2022-12-17 ### Added - `useForm` added `values` props ```tsx const values = await fetch('API'); useForm({ values, // will reset the form when values updates // resetOptions: { // keepDirtyValues: true // } }); ``` - new `isLoading` formState for async `defaultValues` ```tsx const { formState: { isLoading }, } = useForm(); ``` ### Changed - `useForm` support async `defaultValues` props ```tsx const { formState: { isLoading }, } = useForm({ defaultValues: fetch('API'), // resetOptions: { // keepDirtyValues: true // } }); ``` ## [7.40.0] - 2022-11-30 ### Changed - async validation (or combined with sync) will always the take the latest validation result and abort the previous ## [7.39.5] - 2022-11-21 ### Changed - Conditional render `useFormState` will trigger an extra re-render to reflect the current `formState` ## [7.39.0] - 2022-11-2 ### Changed - `isValid` formState is no longer only applicable with `onChange`, `onTouched`, and `onBlur` mode. ## [7.38.0] - 2022-10-19 ### Added - support build-in validation with input type week and time ```tsx ``` ## [7.37.0] - 2022-10-07 ### Added - new formState `defaultValues` ```tsx const { formState, watch } = useForm({ defaultValues: { name: 'test' }, }); const { defaultValues } = useFormState(); const name = watch('name'); return (

Your name was {defaultValues.name}

Updated name is {name}

); ``` ### Changed - defaultValues: complex object data contains prototype methods will not be cloned internally ## [7.36.0] - 2022-9-20 ### Added - reset to support callback syntax ```tsx reset((formValues) => { return { ...formValues, partialData: 'onlyChangeThis', }; }); ``` ## [7.35.0] - 2022-9-10 ### Added - new type `FieldPathByValue` field path by value generic implementation ```tsx function CustomFormComponent< TFieldValues extends FieldValues, Path extends FieldPathByValue, >({ control, name }: { control: Control; name: Path }) { const { field } = useController({ control, name, }); } function App() { const { control } = useForm<{ foo: Date; baz: string; }>(); return ( {/* no error */} {' '} {/* throw an error since baz is string */} ); } ``` ### Changed - form context support children prop type ```tsx
// ✅
// ✅ ``` ## [7.34.0] - 2022-7-28 ### Added - Build in validation support for `useFieldArray` with `rules` prop ```tsx useFieldArray({ name: 'test', rules: { required: true, minLength: 2, maxLength: 10, validate: (fieldArrayValues) => { if (fieldArrayValues[2].title === 'test') { return 'validate Error'; } }, }, }); errors?.test?.root?.message; // access root level errors ``` ## [7.33.0] - 2022-6-24 ## Breaking Change - `@hookform/resolvers` needs to upgraded to version `^2.9.3` above - `useFormContext` do always required to provide a generic type check for your form, without providing generic will now require developers to convert error messages to `String` to pass the type check ```tsx useFormContext(); // ✅ correct usage by provide form type defination const { formState } = useFormContext(); // if generic is missing String(formState.errors?.input?.message); // will need to convert to string ``` ### Changed - Deprecate `NestedValue` and `UnpackNestedValue` type, will be **removed** in the next major version. **Important**: If you are using them, it may cause TS compile error, so please just remove the type usage. ```diff type FormValues = { - select: NestedValue<{ - nested: string - }> + select: { + nested: string + } } type Data = UnpackNestedValue ``` - `formState`'s `errors` is now mapped/merged with `FieldError` - `UseFormHandleSubmit` has removed unused function generic ## [7.32.0] - 2022-6-10 ### Changed - `UseFormRegisterReturn` name type change from `string` to `TFieldName` ## [7.31.0] - 2022-5-11 ### Added - new: `reset` optional prop: `keepDirtyValues` ```tsx reset( { firstName: 'bill', // if firstName is dirty then the value will be retained lastName: 'luo', }, { keepDirtyValues: true }, // keep any changed field ); ``` ### Changed - `useFieldArray` auto-correct field array errors on user action ```tsx const { append } = useFieldArray(); append({ data: '' }); // will auto correct existing field array errors if any ``` ## [7.30.0] - 2022-4-17 ### Changed - improve checkboxes value determine by defaultValues ```tsx useForm({ defaultValues: { checkboxes: [], // register checkbox will be determine as array of checkboxes }, }); register('checkboxes'); // will return array as value ``` ## [7.29.0] - 2022-3-30 ### Changed - tsconfig config change from es2017 to es2018 ## [7.28.0] - 2022-3-13 ### Changed - `register` API options `deps` now support string ```tsx register('test', { deps: 'test' }); ``` ## [7.27.0] - 2022-2-11 ### Added - new option for `setFocus` to select the entire field value ```tsx setFocus('fieldName', { shouldSelect: true }); ``` ## [7.25.2] - 2022-1-29 ### Changed - `onTouched` mode will honor `focusout` event ## [7.25.0] - 2022-1-22 ### Added - `getFieldState` get individual field state ```tsx export default function App() { const { register, getFieldState, formState: { isDirty, isValid }, } = useForm({ mode: 'onChange', defaultValues: { firstName: '', }, }); // you can invoke before render or within the render function const fieldState = getFieldState('firstName'); return (

{getFieldState('firstName').isDirty && 'dirty'}

{getFieldState('firstName').isTouched && 'touched'}

); } ``` ## [7.24.0] - 2022-1-14 ### Changed - `useController` return prop: `onChange`, `onBlur` and `ref` will be memorized with `useCallback` ## [7.23.0] - 2022-1-12 ### Changed - `useFieldArray` change `keyName` is no longer required when field value contains `id` ```tsx const App = () => { const { control, register, handleSubmit } = useForm({ defaultValues: { test: [{ id: 'UUID5678', test: 'data' }], // id value will be retained }, }); const { fields, append } = useFieldArray({ control, name: 'test', }); return (
{fields.map((field, index) => { return ; })}
); }; ``` - `useFormState` will no longer fire state update after hook unmount - `UseFormHandleSubmit` type will infer formValues ## [7.22.0] - 2021-12-14 ### Changed - Browser native reset API will no longer be invoked when `reset` provided with value ```tsx const onSubmit = (data) => {}; React.useEffect(() => { if (formState.isSubmitSuccessful) { reset({ something: '' }); } }, [formState, reset]); handleSubmit(onSubmit); ``` to ```tsx const onSubmit = (data) => { setSubmittedData(data); reset(data); // no longer need to have useEffect }; handleSubmit(onSubmit); ``` ## [7.21.0] - 2021-12-06 ### Changed - `shouldUseNativeValidation` will pass down validation props both at client and server render ```tsx const { register } = useForm() // both client and server render ``` ## [7.20.3] - 2021-11-26 ### Changed - register `onChange` will share same logic with `useController` for non standard event payload ```tsx const { onChange } = register('test'); onChange('stringIsValid'); // this is only valid use case for JS ``` - empty node in `formState` will no longer gets unset ## [7.20.0] - 2021-11-19 ### Added - new `exact` prop for `useWatch` - new `exact` prop for `useFormState` ```tsx useWatch({ name: 'test.test', exact: true, }); useFormState({ name: 'test.test', exact: true, }); ``` ### Changed - `useWatch` subscription will occurred at `useEffect` instead before `render` ## [7.19.0] - 2021-11-05 ### Added - new `resetField` API ```tsx const { resetField } = useForm(); resetField('test'); resetField('test', { keepError: true, keepDirty: true, keepTouched: true, defaultValue: 'test1', }); ``` ### Changed - `useController` will return shallow clone value for the following data type on each rerender - object: `{... value}` - array: `[...value]` ## [7.18.1] - 2021-11-02 - revert `FieldPathWithValue` ## [7.18.0] - 2021-10-28 ### Added - bring back `FieldPathWithValue` - schema errors parent object look up ```tsx const validationSchema = object().shape({ questions: array().min(1, 'Array cannot be empty'), }); // the above schema will be picked up by field array action // the logic applies to group error object eg checkboxes ; ``` ## [7.17.0] - 2021-10-02 ### Added - new type `FieldPathWithValue` to improve generic components type support ```tsx type ExpectedType = { test: string }; const Generic = ({ name, control, }: { name: FieldPathWithValue; control: Control; }) => { const { field: { value, ...fieldProps }, } = useController({ name, control, defaultValue: { test: 'value' }, }); return ; }; ``` ## [7.16.1] - 2021-09-27 ### Changed - `formState` subscription no longer subscribed at `useEffect` instead the execution of each hook ## [7.16.0] - 2021-09-25 ### Added - `register` allowed pass custom `onChange` and `onBlur` ```tsx {}, onBlur: (e) => {}, })} /> ``` ## [7.15.0] - 2021-09-05 ### Added - `useFieldArray` new method `replace()` ```tsx const { control } = useForm({ defaultValues: { test: [{ value: 'lorem' }, { value: 'ipsum' }], }, }); const { fields, replace } = useFieldArray({ control, name: 'test', }); const handleFullyReplacement = (): void => { // remove old and set fully new values replace([{ value: 'dolor' }, { value: 'sit' }, { value: 'amet' }]); }; ``` - Improved to not map types defined with `interface`. ```tsx import { useForm } from 'react-hook-form'; interface CustomValue { custom: string; } type FormValues = { fieldName: CustomValue; }; const { formState: errors } = useForm({ defaultValues: { fieldName: { custom: 'value' } }, }); ``` ## [7.14.0] - 2021-08-27 ### Added - `register` add dependent validation ```tsx const App = () => { const { register, getValues } = useForm(); return (
{ return getValues('lastName') === value; }, })} /> // dependant validation
); }; ``` ## [7.13.0] - 2021-08-22 ### Added `Trigger` - Trigger will enable object name trigger and field array name trigger ```tsx useFieldArray({ name: 'test' }); trigger('name'); // will trigger the whole field array to validate ``` `register` - added a `disabled` prop as an option to toggle input disable attribute - register will be able to seek input DOM reference through the `ref` callback ```tsx register('test', { disabled: true }) // will set value to undefined and pass disabled down to the input attribute
// this input will be registered
``` `useWatch` - added `disabled` prop to toggle the state subscription. ```tsx useWatch({ disabled: true }); // you toggle the subscription ``` `useFormState` - added `disabled` prop to toggle the state subscription. ```tsx useFormState({ disabled: true }); // you toggle the subscription ``` `setValue` - allow set value for non-registered inputs include nested object and array field. ```tsx setValue('test', [{ firstName: 'bill' }, {firstName: 'kotaro}, {firstName: 'joris'}]) // this will works ``` ## [7.12.0] - 2021-07-24 ### Added - new `useForm` config `delayError` ```tsx useForm({ delayError: 500, // delay error appear with 500ms }); ``` ## [7.11.0] - 2021-07-13 ### Added - `update` method to update an field array inputs ```tsx const { update } = useFieldArray(); update(0, data); // update an individual field array node ``` ## [7.10.0] - 2021-07-02 ### Changed - `defaultValue` is no longer a required prop for register input with `useFieldArray` ## [7.9.0] - 2021-06-19 ### Added - new config at `useForm` to enabled native browser validation ```tsx const { register, handleSubmit } = useForm({ shouldUseNativeValidation: true, }); ``` ## [7.8.5] - 2021-06-15 ### Change - `useController` no longer access input `ref` except `focus` event for focus management ## [7.8.0] - 2021-06-5 ### Added - `setValue` support `shouldTouch` to update formState touchFields ```tsx setValue('firstName', 'value', { shouldTouch: true }); ``` - `register` now accept `value` as option ```tsx register('firstName', { value: 'value' }); ``` ### Changed - `isValid` will initialise as `false` ## [7.7.1] - 2021-05-30 ### Fixed - `shouldUnregister: false` should not shallow merge or register absent input fields from `defaultValues` ## [7.7.0] - 2021-05-29 ### Added - `trigger` support focus with error input ```ts trigger('inputName', { shouldFocus: true }); ``` ### Changed - `handleSubmit` will `throw` error within the onSubmit callback ## [7.6.0] - 2021-05-15 ### Changed - `useForm` will `register` missing inputs from `defaultValues` ```tsx const App = () => { const { register, handleSubmit } = useForm({ defaultValues: { test: { firstName: 'bill', lastName: 'luo' }, }, }); const onSubmit = (data) => { // missing registered input will be included console.log(data); // { test: { firstName: 'bill', lastName: 'luo' } } }; return (