✨ 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 react-hook-form@8.0.0-beta.5