From 750edc78ff6989ba82781cd8128a3f8d6ff37b35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Fri, 29 Nov 2024 16:50:10 +0100 Subject: [PATCH] refactor(theme-common): change storageUtils useSyncExternalCode getSnapshot workaround (#10728) --- packages/docusaurus-theme-common/src/utils/storageUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/docusaurus-theme-common/src/utils/storageUtils.ts b/packages/docusaurus-theme-common/src/utils/storageUtils.ts index a8c8825b2267..491088f0416f 100644 --- a/packages/docusaurus-theme-common/src/utils/storageUtils.ts +++ b/packages/docusaurus-theme-common/src/utils/storageUtils.ts @@ -229,8 +229,8 @@ export function useStorageSlot( const currentValue = useSyncExternalStore( listen, () => { - // TODO this check should be useless after React 18 - if (typeof window === 'undefined') { + // react-test-renderer (deprecated) never call getServerSnapshot() :/ + if (process.env.NODE_ENV === 'test') { return null; } return storageSlot.get();