We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ae78fc5 commit 27de1cdCopy full SHA for 27de1cd
packages/gitbook/src/components/hooks/useScrollActiveId.ts
@@ -12,11 +12,12 @@ export function useScrollActiveId(
12
) {
13
const { rootMargin, threshold = 0.5 } = options;
14
15
- const [activeId, setActiveId] = React.useState<string | null>(null);
+ const [activeId, setActiveId] = React.useState<string>(ids[0]);
16
const sectionsIntersectingMap = React.useRef<Map<string, boolean>>(new Map());
17
18
React.useEffect(() => {
19
- setActiveId(null);
+ const defaultActiveId = ids[0];
20
+ setActiveId((activeId) => (ids.indexOf(activeId) !== -1 ? activeId : defaultActiveId));
21
22
if (typeof IntersectionObserver === 'undefined') {
23
return;
0 commit comments