fix(epub): prevent stale clearCurrDoc reference on unmount in EPUB page

This commit is contained in:
Richard R 2026-05-27 16:03:34 -06:00
parent a00caa9052
commit f27b5e6504

View file

@ -46,6 +46,7 @@ export default function EPUBPage() {
const inFlightDocIdRef = useRef<string | null>(null);
const loadedDocIdRef = useRef<string | null>(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 = () => {