fix(html): use ref to ensure latest clearCurrDoc on unmount
This commit is contained in:
parent
f27b5e6504
commit
139a227aa4
1 changed files with 8 additions and 3 deletions
|
|
@ -46,6 +46,7 @@ export default function HTMLPage() {
|
||||||
const [maxPadPx, setMaxPadPx] = useState<number>(0);
|
const [maxPadPx, setMaxPadPx] = useState<number>(0);
|
||||||
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 clearCurrDocRef = useRef(clearCurrDoc);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
@ -103,11 +104,15 @@ export default function HTMLPage() {
|
||||||
}, [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