From 2eb491a7348871a6a041f2a91fd50fdcd4666fa1 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kaiser Date: Thu, 29 Feb 2024 15:54:11 +0100 Subject: [PATCH] fix blocker is not stable --- packages/ra-core/src/form/useWarnWhenUnsavedChanges.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/ra-core/src/form/useWarnWhenUnsavedChanges.tsx b/packages/ra-core/src/form/useWarnWhenUnsavedChanges.tsx index af09bd2a70a..35fbae21679 100644 --- a/packages/ra-core/src/form/useWarnWhenUnsavedChanges.tsx +++ b/packages/ra-core/src/form/useWarnWhenUnsavedChanges.tsx @@ -69,7 +69,9 @@ export const useWarnWhenUnsavedChanges = ( } } setShouldNotify(false); - }, [blocker, shouldNotify, translate]); + // Can't use blocker in the dependency array because it is not stable across rerenders + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [shouldNotify, translate]); // This effect handles document navigation, e.g. closing the tab useEffect(() => {