Document version 7.6.0 as a breaking change
See original GitHub issueIs your feature request related to a problem? Please describe. There’s a breaking change that occurred after the release of version 7.6.0. I suspect it is related to https://github.com/react-hook-form/react-hook-form/pull/5069 where we add default values to register even if their corresponding fields are not rendered.
Previously, if we wanted to manually track fields that were not rendered in the HTML, we’d do something like this
const { register } = useForm({
defaultValues: {
manuallyTracked: true,
},
});
useEffect(() => {
register('manuallyTracked');
}, []);
// some functions modifying manuallyTracked state
return (
<html-without-input-named-manually-tracked />
)
With the release of version 7.6.0, we no longer need to call register()
to manually track fields which is great! However, doing so may result in unexpected bugs. In my case, an empty array was becoming an empty object.
Describe the solution you’d like
Document this change and the fact we no longer need nor should call register()
to manually register inputs.
Describe alternatives you’ve considered Downgrading the library version 😂
Additional context N/A
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (6 by maintainers)
Top GitHub Comments
Thank you! I think the second approach with
shouldUnregister
will work as it should essentially be the behaviour prior to7.6.0
, right? Either way I tested it and it appears to work as expected. Thanks againHey @bluebill1049, just wanted to provide you with an update. I was able to isolate the issue related to removing the
register()
call in my code. The bug was in my application, so nothing to fix inreact-hook-form
. Thank you for your fast responses and continued maintenance of this library!