Skip to content

Conversation

@mkhennoussi
Copy link

@mkhennoussi mkhennoussi commented Oct 4, 2022

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 !

@BorjaRafolsMartinez
Copy link

This actually makes this plugin work with defaultValues option from react-hook-form

@Alain1405
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doesn't seem to work on refresh

3 participants