fix(epub): prevent stale clearCurrDoc reference on unmount in EPUB page
This commit is contained in:
parent
a00caa9052
commit
f27b5e6504
1 changed files with 8 additions and 3 deletions
|
|
@ -46,6 +46,7 @@ export default function EPUBPage() {
|
||||||
const inFlightDocIdRef = useRef<string | null>(null);
|
const inFlightDocIdRef = useRef<string | null>(null);
|
||||||
const loadedDocIdRef = useRef<string | null>(null);
|
const loadedDocIdRef = useRef<string | null>(null);
|
||||||
const didInitPadPctRef = useRef(false);
|
const didInitPadPctRef = useRef(false);
|
||||||
|
const clearCurrDocRef = useRef(clearCurrDoc);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
@ -103,11 +104,15 @@ export default function EPUBPage() {
|
||||||
}, [loadDocument, isLoading]);
|
}, [loadDocument, isLoading]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
clearCurrDocRef.current = clearCurrDoc;
|
||||||
clearCurrDoc();
|
|
||||||
};
|
|
||||||
}, [clearCurrDoc]);
|
}, [clearCurrDoc]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => {
|
||||||
|
clearCurrDocRef.current();
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
// Compute available height = viewport - (header height + tts bar height)
|
// Compute available height = viewport - (header height + tts bar height)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const compute = () => {
|
const compute = () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue