|
8 | 8 | type HtmlRenderReference, |
9 | 9 | } from "@t3tools/shared/htmlRender"; |
10 | 10 | import { Maximize2Icon } from "lucide-react"; |
11 | | -import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"; |
| 11 | +import { useEffect, useLayoutEffect, useRef, useState } from "react"; |
12 | 12 |
|
13 | 13 | import { useAssetUrlRefresh, useAssetUrlState } from "~/assets/assetUrls"; |
14 | 14 | import { cn } from "~/lib/utils"; |
@@ -45,28 +45,25 @@ export function HtmlRenderFrame(props: { |
45 | 45 | const [contentHeight, setContentHeight] = useState<number>(); |
46 | 46 | const height = htmlRenderFrameHeight(props.htmlRender, width, contentHeight); |
47 | 47 | const fileName = htmlRenderFileName(title); |
48 | | - const resource = useMemo( |
49 | | - () => ({ |
50 | | - _tag: "attachment" as const, |
51 | | - attachmentId, |
52 | | - fileName, |
53 | | - mimeType: "text/html", |
54 | | - disposition: "inline" as const, |
55 | | - }), |
56 | | - [attachmentId, fileName], |
57 | | - ); |
| 48 | + const resource = { |
| 49 | + _tag: "attachment" as const, |
| 50 | + attachmentId, |
| 51 | + fileName, |
| 52 | + mimeType: "text/html", |
| 53 | + disposition: "inline" as const, |
| 54 | + }; |
58 | 55 | // A cached URL with life left is reused, so the browser's cache serves the |
59 | 56 | // page again; one near expiry is minted afresh, since a frame cannot report a |
60 | 57 | // failed load. |
61 | 58 | const [src, setSrc] = useState<string | null>(null); |
62 | 59 | const srcExpiresAt = useRef(0); |
63 | 60 | const [expandedSrc, setExpandedSrc] = useState<string | null>(null); |
64 | 61 | const [ready, setReady] = useState(false); |
65 | | - const showPage = useCallback(() => setReady(true), []); |
66 | | - const fitPage = useCallback((contentHeight: number) => { |
| 62 | + const showPage = () => setReady(true); |
| 63 | + const fitPage = (contentHeight: number) => { |
67 | 64 | setContentHeight(contentHeight); |
68 | 65 | setReady(true); |
69 | | - }, []); |
| 66 | + }; |
70 | 67 | const { onFullscreenChange } = props; |
71 | 68 | useEffect(() => { |
72 | 69 | if (expandedSrc === null) return; |
|
0 commit comments