Repository navigation
Releases
Version 7.92.0
🐞 Fixes
- Fix
useFormStateandControllerunnecessarily cloning form state during mount and unmount (#13945) - Fix
setValuesnot updating dirty state for unregistered fields (#13946) - Fix form state values becoming inconsistent (#13948)
- Fix
setValuenot selecting checkbox options with empty string values (#13950) - Fix stale asynchronous form-level validation results (#13951, #13954)
- Fix
useFieldArrayapplyingreValidateMode: 'onSubmit'before submission (#13952) - Fix default values not being applied correctly to selects with disabled optgroups (#13953)
- Fix
useControllerreading staleshouldUnregisteroptions (#13956, #13996) - Fix focusing disabled radio and checkbox inputs (#13960, #13968, #13977)
- Fix TypeScript type regression (#13963)
- Fix field array notifications using stale values (#13965)
- Fix rejected submission callbacks with falsy rejection reasons (#13967)
- Fix
useWatchmissingreset()updates on mount in React Native (#13974) - Fix
triggerlosing nested field array root errors (#13975) - Fix
unregisterretaining descendant registrations when removing a parent (#13976) - Fix
triggernot marking nested fields as touched whenshouldTouchtargets a parent (#13978) - Fix
useWatchcompute cache not synchronizing whencomputeis removed (#13987) - Fix
setValuesignoring options when values remain unchanged (#13989) - Fix
handleSubmitincorrectly updating form state afterreset()during asynchronous callbacks (#13991) - Fix
useFieldArrayretaining validation rules after the rules prop is removed (#13992) - Fix
resetnot updatingisValidafter cancelling pending validation (#13994) - Fix TypeScript nested array paths not preserving
undefined(#13995) - Fix
<Form />not respectingencTypewhen constructing request bodies (#13997) - Fix
handleSubmitnot supporting nullish and primitive transformed values with disabled fields (#13999, #14011) - Fix
useControllerdirty tracking with controller-leveldefaultValue(#14001) - Fix multi-select changes including disabled options (#14002)
- Fix
registeroverwriting untouched range and color input defaults (#14007) - Fix stale schema resolver errors after field array operations (#14008)
- Fix
unsetfailing on primitive values (#14014) - Fix form-level validation errors appearing before submission during
isValidchecks (#14015) - Fix stale field errors when form-level validation returns a message (#14016)
- Fix repeated
reset()calls and error focusing withkeepFieldsRefand memoized inputs (#14023)
⚡ Performance Improvements
- Avoid unnecessary form state cloning in
useFormStateandController(#13945)
🧹 Refactors
- Skip non-dirty array holes when collecting dirty field names (#13979)
- Avoid mutating field metadata when building resolver options (#13984)
🧪 Tests
- Expand regression coverage for
reset,useController,useFieldArray, validation, dirty state and form submissions - Add regression coverage for disabled radio and checkbox inputs, React Native reset handling, and primitive transformed values
📦 Dependencies
- Bump
fast-urifrom 3.1.8 to 3.1.9 (#13949) - Bump
follow-redirectsfrom 1.16.1 to 1.16.2 (#13985) - Bump
vitefrom 6.4.4 to 6.4.5 (#13983) - Bump
joifrom 18.2.9 to 18.3.1 (#13986)
❤️ Thank You
Thanks to @charan-rathore, @clean99, @KooYS, @dfedoryshchev, @maxymlyskov, @aumilkyeong, @hamarshehmhmd, @zigzagdev, @wozhenbang2004, @Aminark, @zendesk-robryan, @MomenSherif, @Shellghostt, @SatyamGangani, @yxshee, @timsnadden and @bluebill1049 for their contributions! 🎉
Special thanks to the Pennylane team for their incredible support! ❤️
Version 8.0.0-beta.5
✨ Improvements
- Sync v8 with the latest
masterbranch, including all fixes and improvements from v7.90.0 and v7.91.0 - Improve React Compiler compatibility and add full test coverage with React Compiler (#13864)
- Improve
useFieldArraysupport for flat and primitive arrays (#13890, #13927, #13936) - Preserve
null,undefinedand falsy values in primitive field arrays (#13890, #13936) - Expose primitive field array rows with generated
keyandvalueproperties (#13927) - Improve v8 TypeScript definitions and API consistency (#13887)
🐞 Fixes
- Fix
useFieldArraynot updating rows when usingsetValueorsetValues(#13842, #13939) - Fix
useFieldArrayunregistering values incorrectly on unmount (#13843) - Fix field registration without a value incorrectly adding array rows (#13846, #13849)
- Fix
useFieldArrayreindexing fields incorrectly when array rules are registered (#13873) - Fix
useFieldArraylosing validation rules afterreset()(#13940) - Fix stale field array validation results after array changes (#13888)
- Fix
useFieldArrayvalidation after submission inonBlurmode (#13867) - Fix stale asynchronous validation results after
reset()andunregister()(#13908, #13912, #13934) - Fix
Controllervalidation using stale DOM values (#13880) - Fix
isValidnot updating correctly afterreset()and subsequent changes (#13847, #13930) - Fix
handleSubmitleavingisSubmittingactive when validation throws (#13905) - Fix empty validation message arrays being treated as errors (#13937)
- Fix delayed validation errors not being flushed on blur (#13861)
- Fix dirty state tracking and
resetField()with falsy values (#13868, #13900) - Fix
unregisterretaining validation rules when usingkeepValue(#13891) - Fix
<Form />handling of JSON, URL-encoded, multipart and plain-text submissions (#13848, #13854, #13874, #13893, #13907, #13915, #13926) - Fix
useWatchnot updating default values when the watched name changes (#13859) - Fix select options being lost before the form is ready (#13872)
- Fix
useFormretaining removed options and disabled state (#13882, #13883, #13889, #13898) - Fix object comparison for null-prototype objects and sparse arrays (#13853, #13855, #13857)
- Fix
setValuehandling null-prototype objects (#13916) - Fix
useFormmutating externally provided errors (#13896)
⚡ Performance Improvements
- Improve
getValues()performance by avoiding unnecessary copies (#13894) - Reduce unnecessary
<Form />re-renders (#13899) - Improve form state subscriptions and dirty field tracking
⚠️ Breaking Changes
- Replace
anywithunknownin public types, requiring explicit typing or narrowing where appropriate - Rename the generated
useFieldArrayfield identifier fromidtokey - Remove the
keyNameprop fromuseFieldArray - Rename the
<Watch />prop fromnamestoname(#13879) - Remove the
watch(callback)API; usesubscribe()instead - Use input refs instead of partial refs (#12773)
- Return
nullinstead ofInvalid Datefor empty values withvalueAsDate: true(#13901) - Update reference stability for selected
useFormmethods to support React Compiler
Migration guide: https://react-hook-form.com/migrate-v7-to-v8
🧹 Refactors
- Improve internal TypeScript definitions and API consistency (#13871, #13886, #13887)
- Simplify multipart Content-Type handling (#13926)
- Remove unsupported
<Watch />properties (#13879)
🧪 Tests
- Add React Compiler test coverage (#13864)
- Add regression coverage for primitive field arrays, including nullish and falsy values (#13890, #13927, #13936)
- Expand regression coverage for
useFieldArray, validation, reset and form state
❤️ Thank You
Thanks to @vicuts, @maxymlyskov, @ahamsel, @dasjideepak, @feritcemkahraman, @DahanItamar, @arba-octo, @dfedoryshchev, @jeremiah-white, @TiagoGranelli, @zigzagdev, @nandyx, @hardikkaurani, @Marve10s, @candymask0712, @saaahilhussain, @itisrmk, @Enesuygurs, @kotarella1110 and @bluebill1049 for their contributions! 🎉
Special thanks to the Pennylane team for their incredible support! ❤️
📦 Installation
npm install [email protected]Version 7.91.0
🐞 Fixes
- Fix
useFieldArraynot updating rows when usingsetValueorsetValues(#13842, #13939) - Fix
useFieldArraynot unregistering values correctly on unmount (#13843) - Fix field registration without a value incorrectly adding array rows (#13846, #13849)
- Fix
useFieldArrayreindexing fields incorrectly when array rules are registered (#13873) - Fix
useFieldArraylosing validation rules afterreset()(#13940) - Fix stale field array validation results after array changes (#13888)
- Fix
useFieldArrayvalidation after submission inonBlurmode (#13867) - Fix dirty state updates when
setValueschanges field arrays (#13870) - Fix stale asynchronous validation results after
reset()andunregister()(#13908, #13912, #13934) - Fix
Controllervalidation using stale DOM values (#13880) - Fix
isValidnot updating correctly afterreset()and subsequent changes (#13847, #13930) - Fix
handleSubmitleavingisSubmittingactive when validation throws (#13905) - Fix empty validation message arrays being treated as errors (#13937)
- Fix delayed validation errors not being flushed on blur (#13861)
- Fix form state subscriptions and validity updates (#13866, #13877, #13906)
- Fix dirty state tracking and
resetField()with falsy values (#13868, #13900) - Fix
unregisterretaining validation rules when usingkeepValue(#13891) - Fix
<Form />handling of JSON, URL-encoded, multipart and plain-text submissions (#13848, #13854, #13874, #13893, #13907, #13915, #13926) - Fix
useWatchnot updating default values when the watched name changes (#13859) - Fix select options being lost before the form is ready (#13872)
- Fix
useFormretaining removed options and disabled state (#13882, #13883, #13889, #13898) - Fix progressive required attributes (#13924)
- Fix numeric zero
maxLengthvalidation (#13851) - Fix object comparison for null-prototype objects and sparse arrays (#13853, #13855, #13857)
- Fix
cloneObjecthandling objects with aconstructorkey (#13875) - Fix
setValuehandling null-prototype objects (#13916) - Fix form-level validation error types (#13860)
- Fix
useFormmutating the externally providederrorsobject (#13896) - Fix stale
NaNand invalid date validation results (#13910)
⚡ Performance Improvements
- Avoid unnecessary copies when calling
getValues()(#13894) - Reduce unnecessary
<Form />re-renders (#13899)
🧹 Refactors
- Simplify multipart Content-Type handling (#13926)
- Improve internal types and remove unnecessary type assertions (#13871, #13886)
- Clean up memoized component display names (#13897)
- Fix JSDoc examples (#13895)
🧪 Tests
- Add coverage for disabled field array operations (#13841)
- Expand regression coverage for
useFieldArray,reset, validation and form state
📦 Dependencies
- Bump
joifrom 18.2.6 to 18.2.9 (#13836) - Update
browserslistandbaseline-browser-mapping(#13837, #13838, #13839) - Bump
follow-redirectsfrom 1.16.0 to 1.16.1 (#13913) - Bump
vitefrom 6.4.3 to 6.4.4 (#13914)
❤️ Thank You
Thanks to @vicuts, @maxymlyskov, @ahamsel, @dasjideepak, @feritcemkahraman, @DahanItamar, @arba-octo, @dfedoryshchev, @jeremiah-white, @TiagoGranelli, @zigzagdev, @nandyx, @hardikkaurani, @Marve10s, @candymask0712, @saaahilhussain, @itisrmk, @Enesuygurs and @bluebill1049 for their contributions! 🎉
Special thanks to the Pennylane team for their incredible support! ❤️
Version 7.90.0
🐞 Fixes
- Fix
useFormmarking fields named afterObject.prototypemembers as touched on blur andsetValue(#13833) - Fix
cloneObjectpreserving the length of sparse arrays (#13834) - Fix dirty values extraction for fields named
hasOwnProperty(#13832) - Fix
useFormretaining options removed from props on re-render (#13831) - Fix
useFieldArrayhandling duplicate indexes inremove()without mutating the provided indexes (#13830) - Fix
useFieldArrayunregistering fields while a parent array reindexes (#13828) - Fix input values edited before the form is ready being lost (#13827)
- Fix
useWatchnot updating watched objects after an Activity subtree reconnects (#13819) - Fix
reset()incorrectly settingisDirtywhen usingkeepDefaultValueswithout values (#13820) - Fix
Controllerblur validation not working afterreset()(#13817) - Fix
watchusing staleshouldUnregisteroptions when registering fields (#13814) - Fix form value comparison for fields named
ref(#13812) - Fix native validation using stale
shouldUseNativeValidationoptions (#13806) - Fix
cloneObjectnot cloning objects with a null prototype (#13808) - Fix
useWatcharray names not prioritizing formdefaultValues(#13805) - Fix error updates not producing a new
errorsreference (#13800) - Fix
setErrorandclearErrorsnot producing a newerrorsreference (#13791)
⚡ Performance Improvements
- Improve dirty fields checking (#13788)
- Improve subscription value handling (#13787)
- Improve
watchAPI performance (#13792) - Improve named scoped subscriptions (#13793)
- Preserve form-state tracking across unsubscribe (#13794)
- Improve subject subscription handling (#13795)
- Skip redundant form-state merges during subscriber notifications (#13796)
- Avoid allocations when matching subscription names (#13823)
🧹 Refactors
🧪 Tests
- Add coverage for
useFieldArrayindex boundary and no-op behavior (#13815, #13822, #13824, #13829) - Add coverage for JSON stringify and parse edge cases (#13821)
📦 Dependencies
❤️ Thank You
Thanks to @charan-rathore, @zigzagdev, @AdzerKI, @huytdps13400, @dfedoryshchev, @kory-kaai, @Mohamed-Elshesheny, @breken-ai, @sarmah-rup, @00200200, @giaBaoJS and @bluebill1049 for their contributions! 🎉
Version 8.0.0-beta.4
🦾 Syncs v8 beta with the latest master branch, bringing over recent v7 bug fixes, performance improvements, refactors, and DX updates.
Version 7.89.0
🐞 Fixes
- Fix form state select option (#13784)
- Remove duplicate default value field (#13783)
- Fix
validateFieldskipping refs withoutsetCustomValidityunder native validation (#13782) - Fix form-level validation using a stale
validatefunction (#13777) - Fix
useFieldArraytouched fields handling (#13776) - Fix pending
delayErrortimers for nested paths (#13775) - Fix
getValuesextracting unmarked field array entries (#13773) - Fix field array touched state not being re-indexed when unsubscribed (#13772)
- Fix nested
delayErrortimers remaining when a parent validates clean (#13771) - Fix nested
delayErrortimers remaining afterresetField()resets a parent (#13769) - Fix stale field array root errors after an operation satisfies the validation rule (#13767)
- Fix
setValue()not revalidating dependencies whenshouldValidateis enabled (#13765) - Fix stale built-in validation results after
reset()duringhandleSubmit()(#13761) - Fix stale form-level validation results after
reset()(#13762) - Fix validation rules removed from
registeroptions at runtime remaining active (#13758) - Fix
useControllerrequired validation not using the controlled value (#13756) - Fix stale form-level errors remaining after successful re-validation (#13755)
- Fix
useFieldArraymarking the form dirty when the array default value isnull(#13750) - Fix
isValidnot being recomputed when theerrorsprop is emptied (#13748) - Fix form-level validation running more than once per traversal (#13747)
- Fix stale built-in validation results after
reset()duringonChange(#13745) - Fix stale resolver results after
reset()duringonChange(#13744) - Fix
setValue()not triggering field array root validation whenshouldValidateis enabled (#13743) - Fix
getFieldState(name, formState)updates afterreset()(#13741) - Fix dirty state remaining for rows removed from a field array (#13739)
🧹 Refactors
📦 Dependencies
- Add optional
@types/reactpeer dependency (#13781)
❤️ Thank You
- Thanks to @niketchandivade, @unrevised6419, @Lucasfarg, @dfedoryshchev, @locphamnice, @Abdalluh28, @giaBaoJS, @Mohamedshawky4, @roli-lpci, @soroush5, @zigzagdev and @bluebill1049 for their contributions! 🎉
Version 7.88.0
✨ Features
- Add Error Message component (#13472)
- Add the Error Message component for displaying validation errors from React Hook Form.
🐞 Fixes
- Fix stale validating state after
resetField()(#13735) - Fix errors and touched state remaining for rows removed by
replace()(#13734) - Fix stale resolver results updating form state after
reset()duringhandleSubmit()(#13733) - Fix nested registered errors being removed when
trigger()targets their parent (#13732) - Fix resolver-reported root errors being dropped during
handleSubmit()(#13731) - Fix parent errors being incorrectly set when
trigger()targets a field with only nested resolver errors (#13730) - Fix
useWatchcompute cache not being initialized with the initial output (#13728) - Fix
FileListbeing lost during flatten/expand and omit undefined values injsonToFormData(#13725) - Fix
schemaErrorLookupreporting nested containers as exact-name errors (#13727) - Fix
isValidatingnot being recomputed afterunregister()clears validating fields (#13723) - Fix stale resolver state updates after
reset()(#13722) - Fix
iterateFieldsByActiononly breaking out of one loop level (#13718) - Fix stale validation types surviving
setError()overwrites (#13716) - Fix
reset()not clearing validating fields (#13714) - Fix
remove()leaking deleted values onto surviving field-array items (#13713) - Fix the React Server build being unpublished (#13709)
- Fix
validateFieldcallingsetCustomValidityonce per key in validate-object mode (#13707) - Fix
useFieldArrayfocus behavior for checkboxes and radio buttons in appended rows (#13705) - Fix
getFieldStatereadingisValidatingfrom the supplied form state (#13704) - Fix
unregister()stripping kept values from the submit payload (#13703) - Fix
useFormStatenot re-subscribing when control changes (#13702) - Fix
reset()keepingdirtyFieldsout of sync withisDirtywhenkeepValuesis enabled (#13701) - Fix
useFormnot reconciling correctly when an Activity subtree is initially hidden (#13698) - Fix cleared errors returning after the
delayErrortimer fires (#13697) - Fix
cloneObjectthrowing when checkingBlobwithinstanceof(#13694) - Fix
useFieldArrayretaining stale fields after an Activity subtree reconnects (#13688)
🧹 Refactors
- Extend
_isTrackedto the remaining multi-key proxy/subscribe form-state checks (#13699) - Extract
_isTrackedhelper for proxy/subscribe form-state checks (#13690) - Remove the unused
abortEarlyparameter fromiterateFieldsByAction(#13689) - Remove redundant optional chaining from
clearErrors(#13696)
📝 Documentation
- Fix
useWatchcompute example variable names in JSDoc (#13700)
📦 Dependencies
- Bump
joifrom 18.2.1 to 18.2.5 (#13719)
❤️ Thank You
- Thanks to @soroush5, @bluebill1049, @Tnalxmsk, @zigzagdev, @dfedoryshchev, @Alioth-91, @giaBaoJS and @jliew for their contributions! 🎉
Version 7.87.0
✨ 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! 🎉
Version 7.86.0
✨ Features
🐞 Fixes
- Fix
useWatchreturning stale values when the watched name changes tonull. (#13668) - Fix
unregisterkeepDirtybehavior. (#13669) - Fix
setValuesfor fields registered under object or array values. (#13667) - Fix
Controllernotifications for field array item roots. (#13665) - Fix validation state checks. (#13661)
- Fix
setCustomValiditywithcriteriaMode: 'all'. (#13655) - Fix
File,Blob, andFileListhandling inflatten. (#13652) - Fix stale errors and touched state after updating a field array item. (#13650)
- Fix stale field names leaking into persisted
formState. (#13649)
🚀 Performance
- Improve
createFormControlperformance. (#13648) - Improve
cloneObjectperformance. - Avoid unnecessary value cloning in
unregister. (#13662) - Improve performance in
onChange-heavy workloads.
🧹 Chores & Refactoring
- Remove unnecessary
anyusage. (#13660) - Improve TypeScript handling around checkbox values. (#13659)
- Improve UUID generation. (#13658)
- Clean up repository structure and APIs. (#13657)
- Remove unreachable revalidation logic in
useFieldArray. (#13654)
Thanks to @dfedoryshchev, @zigzagdev, @official-burak, @Jaybhade, @candymask0712, and @bluebill1049 for their contributions! 🎉
Version 7.85.0
✨ Improvements
- support React
<Activity />(#13633)
🐞 Fixes
- fix min/max validation being skipped for
valueAsDatefields (#13646) - fix field array root errors being lost during
append,prepend,insert, andremove(#13645) - fix stale renders recreating field array paths after field array actions (#13644)
- fix
useWatchpreferring formdefaultValuesover the hook's owndefaultValue(#13635) - fix
setValueemitting duplicatevaluesstate notifications (#13637) - fix TypeScript
getFieldStateerror resolution for field paths (#13632)
🏗️ Chores
Thanks to @zigzagdev, @bluebill1049, @anshusaurav, @saulo-silva, @EduardF1, and @candymask0712 for their contributions! 🎉