useBlocker and React Hook Form #11599
Replies: 5 comments
-
We are running into a similar issue. We don't use reset, so it's not |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
any updates? |
Beta Was this translation helpful? Give feedback.
-
I had this problem with RHF's reset as well. What I did was add another condition in my Setting up an external store with Jotai:const blockerStore = createStore();
export const blockerActiveOverrideAtom = atom(true);
export const setIsBlockerActiveOverride = (val) => blockerStore.set(blockerActiveOverrideAtom, val);
export const getIsBlockerActiveOverride = () => blockerStore.get(blockerActiveOverrideAtom); my useBlocker would look like this const blocker = useBlocker(() => isDirty && getIsBlockerActiveOverride()); So instead of resetting the form, you can just set |
Beta Was this translation helpful? Give feedback.
-
Any updates? |
Beta Was this translation helpful? Give feedback.
-
Hello!
I'm using useBlocker on my application. The scenario is the following:
Is there a way useBlocker could have a dependency in which I would use my isDirty so it is updated when it gets called?my workaround for now is put a setTimeout around my navigation so it gets called after reset is done.
Beta Was this translation helpful? Give feedback.
All reactions