Skip to content

Commit

Permalink
fix: add dependency highlights in function callback scrollToHighlight…
Browse files Browse the repository at this point in the history
…FromHash
  • Loading branch information
thai.ly committed Dec 16, 2024
1 parent ae0968f commit 1da8354
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ export function App() {

const scrollViewerTo = useRef((highlight: IHighlight) => {});

// biome-ignore lint/correctness/useExhaustiveDependencies(a): <inside getHighlightById is using array highlights>
const scrollToHighlightFromHash = useCallback(() => {
const highlight = getHighlightById(parseIdFromHash());
if (highlight) {
scrollViewerTo.current(highlight);
}
}, []);
}, [highlights]);

useEffect(() => {
window.addEventListener("hashchange", scrollToHighlightFromHash, false);
Expand Down

0 comments on commit 1da8354

Please sign in to comment.