diff --git a/src/app/(app)/epub/[id]/page.tsx b/src/app/(app)/epub/[id]/page.tsx index bfa5d6d..d92e358 100644 --- a/src/app/(app)/epub/[id]/page.tsx +++ b/src/app/(app)/epub/[id]/page.tsx @@ -46,6 +46,7 @@ export default function EPUBPage() { const inFlightDocIdRef = useRef(null); const loadedDocIdRef = useRef(null); const didInitPadPctRef = useRef(false); + const clearCurrDocRef = useRef(clearCurrDoc); useEffect(() => { setIsLoading(true); @@ -103,11 +104,15 @@ export default function EPUBPage() { }, [loadDocument, isLoading]); useEffect(() => { - return () => { - clearCurrDoc(); - }; + clearCurrDocRef.current = clearCurrDoc; }, [clearCurrDoc]); + useEffect(() => { + return () => { + clearCurrDocRef.current(); + }; + }, []); + // Compute available height = viewport - (header height + tts bar height) useEffect(() => { const compute = () => {