diff --git a/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx b/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx index 73f74dee01f..70f8918cbff 100644 --- a/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx +++ b/packages/sanity/src/structure/panes/document/DocumentPaneProvider.tsx @@ -748,8 +748,9 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => { ) useEffect(() => { + let timeout: NodeJS.Timeout if (connectionState === 'reconnecting') { - setTimeout(() => { + timeout = setTimeout(() => { pushToast({ id: 'sanity/structure/reconnecting', status: 'warning', @@ -757,6 +758,9 @@ export const DocumentPaneProvider = memo((props: DocumentPaneProviderProps) => { }) }, 2000) // 2 seconds, we can iterate on the value } + return () => { + if (timeout) clearTimeout(timeout) + } }, [connectionState, pushToast, t]) const disableBlurRef = useRef(false)