diff --git a/src/app/(app)/html/[id]/page.tsx b/src/app/(app)/html/[id]/page.tsx
index 76f6d11..4272c3b 100644
--- a/src/app/(app)/html/[id]/page.tsx
+++ b/src/app/(app)/html/[id]/page.tsx
@@ -46,6 +46,7 @@ export default function HTMLPage() {
const [maxPadPx, setMaxPadPx] = useState(0);
const inFlightDocIdRef = useRef(null);
const loadedDocIdRef = useRef(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 = () => {