react-hook-form-persist
react-hook-form-persist copied to clipboard
Fix/fix development error with react strict mode
Hello.
This fixes a bug that happens when using react-hook-form
with defaultValues
option.
https://beta.reactjs.org/learn/synchronizing-with-effects#how-to-handle-the-effect-firing-twice-in-development
It basically makes sure it only runs once using the good old _mounted ref.
Should fix: https://github.com/tiaanduplessis/react-hook-form-persist/issues/18
I also added a test.
@tiaanduplessis
this works for me, thank you, I believe it should be merged
Can we merge this please? I would like to have this soon otherwise will have to patch it manually
tbh I think this PR makes a bunch of changes that are unrelated to the original issue