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 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 = () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue