From 495816fae19b9d5b5c6648258038e4bc0ffb4fd8 Mon Sep 17 00:00:00 2001 From: Anthony D'Andrea Date: Thu, 24 Oct 2024 16:12:06 -0700 Subject: [PATCH] Wrap resetDirty in a useCallback to prevent needless hook fires when added to a dependency array. --- .../form/src/hooks/use-form-status/use-form-status.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/@mantine/form/src/hooks/use-form-status/use-form-status.ts b/packages/@mantine/form/src/hooks/use-form-status/use-form-status.ts index 88423549bd3..81c6c1d1d36 100644 --- a/packages/@mantine/form/src/hooks/use-form-status/use-form-status.ts +++ b/packages/@mantine/form/src/hooks/use-form-status/use-form-status.ts @@ -79,13 +79,13 @@ export function useFormStatus>({ const resetTouched: ResetStatus = useCallback(() => setTouched({}), []); - const resetDirty: ResetDirty = (values) => { + const resetDirty: ResetDirty = useCallback((values) => { const newSnapshot = values ? { ...values, ...$values.refValues.current } : $values.refValues.current; $values.setValuesSnapshot(newSnapshot); setDirty({}); - }; + }, []); const setFieldTouched: SetFieldTouched = useCallback((path, touched) => { setTouched((currentTouched) => {