mirror of
https://github.com/rishikanthc/Scriberr.git
synced 2026-06-28 06:46:25 +00:00
fix lint in TOC
This commit is contained in:
committed by
Rishikanth Chandrasekaran
parent
5d11f318d5
commit
2db72409da
@@ -29,7 +29,8 @@ export function TableOfContents() {
|
||||
};
|
||||
});
|
||||
|
||||
setHeadings(items);
|
||||
// Defer the state update to avoid "setState in effect" warning and render cascades
|
||||
const timeoutId = setTimeout(() => setHeadings(items), 0);
|
||||
|
||||
const observer = new IntersectionObserver(
|
||||
(entries) => {
|
||||
@@ -44,7 +45,10 @@ export function TableOfContents() {
|
||||
|
||||
elements.forEach((elem) => observer.observe(elem));
|
||||
|
||||
return () => observer.disconnect();
|
||||
return () => {
|
||||
clearTimeout(timeoutId);
|
||||
observer.disconnect();
|
||||
};
|
||||
}, [location.pathname]);
|
||||
|
||||
if (headings.length === 0) return null;
|
||||
|
||||
Reference in New Issue
Block a user