fix(html): use ref to ensure latest clearCurrDoc on unmount

This commit is contained in:
Richard R 2026-05-27 16:12:09 -06:00
parent f27b5e6504
commit 139a227aa4

View file

@ -46,6 +46,7 @@ export default function HTMLPage() {
const [maxPadPx, setMaxPadPx] = useState<number>(0);
const inFlightDocIdRef = useRef<string | null>(null);
const loadedDocIdRef = useRef<string | null>(null);
const clearCurrDocRef = useRef(clearCurrDoc);
useEffect(() => {
setIsLoading(true);
@ -103,11 +104,15 @@ export default function HTMLPage() {
}, [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 = () => {