Open mkhennoussi opened 2 years ago
This actually makes this plugin work with defaultValues option from react-hook-form
I can confirm with this fix the form values are persisted even when defaultValuea
is passed to useForm
. Without this defaultValues
overrides the persisted state.
An alternative solution would be to pass defaultValues
directly to useFormPersist
Hi !
This fixes the issue with data not loaded from the storage as the Effects are fired twice in dev: https://beta.reactjs.org/learn/synchronizing-with-effects#how-to-handle-the-effect-firing-twice-in-development
It simply creates a cleanup function that wirte to the storage after reading it.
Should fix: #18
Hope it helps !