Skip to content

Commit

Permalink
restore useScrollPosition deps
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Oct 15, 2021
1 parent 4b23d48 commit ef656a1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/docusaurus-theme-common/src/utils/scrollUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function useScrollPosition(
position: ScrollPosition,
lastPosition: ScrollPosition | null,
) => void,
deps: unknown[] = [],
): void {
const {scrollEventsEnabledRef} = useScrollController();
const lastPositionRef = useRef<ScrollPosition | null>(getScrollPosition());
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit ef656a1

Please sign in to comment.