From ef656a1f085b7227f750197f3118ecec02fc39dc Mon Sep 17 00:00:00 2001 From: slorber Date: Fri, 15 Oct 2021 17:12:11 +0200 Subject: [PATCH] restore useScrollPosition deps --- .../docusaurus-theme-common/src/utils/scrollUtils.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/docusaurus-theme-common/src/utils/scrollUtils.tsx b/packages/docusaurus-theme-common/src/utils/scrollUtils.tsx index b30ed60ed41b..6bd3e4b766ef 100644 --- a/packages/docusaurus-theme-common/src/utils/scrollUtils.tsx +++ b/packages/docusaurus-theme-common/src/utils/scrollUtils.tsx @@ -99,6 +99,7 @@ export function useScrollPosition( position: ScrollPosition, lastPosition: ScrollPosition | null, ) => void, + deps: unknown[] = [], ): void { const {scrollEventsEnabledRef} = useScrollController(); const lastPositionRef = useRef(getScrollPosition()); @@ -127,7 +128,12 @@ export function useScrollPosition( window.addEventListener('scroll', handleScroll, opts); return () => window.removeEventListener('scroll', handleScroll, opts); - }, [dynamicEffect, scrollEventsEnabledRef]); + }, [ + dynamicEffect, + scrollEventsEnabledRef, + // eslint-disable-next-line react-hooks/exhaustive-deps + ...deps, + ]); } type UseScrollPositionSaver = {