From df7ffbfd2cb9f75bf9e261b9bb0412f58ee3ff1d Mon Sep 17 00:00:00 2001 From: Janessa Garrow Date: Mon, 25 Sep 2023 09:30:50 -0400 Subject: [PATCH] Change arg shape for getWindowSize instead of useWindowSize --- .../src/hooks/useWindowSize.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/docusaurus-theme-common/src/hooks/useWindowSize.ts b/packages/docusaurus-theme-common/src/hooks/useWindowSize.ts index b4e57a47647b..1a36488152e9 100644 --- a/packages/docusaurus-theme-common/src/hooks/useWindowSize.ts +++ b/packages/docusaurus-theme-common/src/hooks/useWindowSize.ts @@ -17,7 +17,11 @@ const windowSizes = { type WindowSize = keyof typeof windowSizes; -function getWindowSize(desktopThresholdWidth = 996): WindowSize { +function getWindowSize({ + desktopThresholdWidth = 996, +}: { + desktopThresholdWidth?: number; +}): WindowSize { if (!ExecutionEnvironment.canUseDOM) { return windowSizes.ssr; } @@ -42,21 +46,17 @@ const DevSimulateSSR = process.env.NODE_ENV === 'development' && true; * In development mode, this hook will still return `"ssr"` for one second, to * catch potential layout shifts, similar to strict mode calling effects twice. */ -export function useWindowSize({ - desktopThresholdWidth = 996, -}: { - desktopThresholdWidth?: number; -}): WindowSize { +export function useWindowSize(desktopThresholdWidth = 996): WindowSize { const [windowSize, setWindowSize] = useState(() => { if (DevSimulateSSR) { return 'ssr'; } - return getWindowSize(desktopThresholdWidth); + return getWindowSize({desktopThresholdWidth}); }); useEffect(() => { function updateWindowSize() { - setWindowSize(getWindowSize(desktopThresholdWidth)); + setWindowSize(getWindowSize({desktopThresholdWidth})); } const timeout = DevSimulateSSR