From ce8e55babccda889229a0f4e689fbad22d0d0c47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Thu, 2 Feb 2023 14:41:33 +0100 Subject: [PATCH] fix(theme-common): prepare usage of useSyncExternalStore compatibility with React 18 (#8618) --- packages/docusaurus-theme-common/src/utils/historyUtils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus-theme-common/src/utils/historyUtils.ts b/packages/docusaurus-theme-common/src/utils/historyUtils.ts index a81663feacbf..06b124a229ac 100644 --- a/packages/docusaurus-theme-common/src/utils/historyUtils.ts +++ b/packages/docusaurus-theme-common/src/utils/historyUtils.ts @@ -56,7 +56,11 @@ export function useHistorySelector( selector: (history: History) => Value, ): Value { const history = useHistory(); - return useSyncExternalStore(history.listen, () => selector(history)); + return useSyncExternalStore( + history.listen, + () => selector(history), + () => selector(history), + ); } /**