From 7aabe2a4fa4f9fa6791abe2eede40b460d34e443 Mon Sep 17 00:00:00 2001 From: SocietyNiu <36916814+SocietyNiu@users.noreply.github.com> Date: Tue, 18 Nov 2025 03:12:05 +0100 Subject: [PATCH] docs: Fix custom storage sync event (#55753) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: fix unexpected storage logic * Update .dumi/hooks/useLocalStorage.ts Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Signed-off-by: 遇见同学 <1875694521@qq.com> --------- Signed-off-by: 遇见同学 <1875694521@qq.com> Co-authored-by: 遇见同学 <1875694521@qq.com> Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- .dumi/hooks/useLocalStorage.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.dumi/hooks/useLocalStorage.ts b/.dumi/hooks/useLocalStorage.ts index ba06cbb422..d66306d386 100644 --- a/.dumi/hooks/useLocalStorage.ts +++ b/.dumi/hooks/useLocalStorage.ts @@ -83,9 +83,15 @@ const useLocalStorage = (key: string, options: Options = {}) => { [key], ); + const shouldSyncCustomEvent = (ev: CustomEvent<{ key: string; storageArea: Storage }>) => { + return ev?.detail?.key === key && ev?.detail?.storageArea === storage; + }; + const onCustomStorage = useCallback( (event: Event) => { - if (shouldSync(event as StorageEvent)) { + const customEvent = event as CustomEvent; + + if (shouldSyncCustomEvent(customEvent)) { setState(getStoredValue()); } },