Skip to content

Commit 16dc003

Browse files
perf(web): the HTML render frame compiles without manual memoization
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a702563 commit 16dc003

1 file changed

Lines changed: 11 additions & 14 deletions

File tree

‎apps/web/src/components/chat/HtmlRenderFrame.tsx‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
type HtmlRenderReference,
99
} from "@t3tools/shared/htmlRender";
1010
import { Maximize2Icon } from "lucide-react";
11-
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
11+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
1212

1313
import { useAssetUrlRefresh, useAssetUrlState } from "~/assets/assetUrls";
1414
import { cn } from "~/lib/utils";
@@ -45,28 +45,25 @@ export function HtmlRenderFrame(props: {
4545
const [contentHeight, setContentHeight] = useState<number>();
4646
const height = htmlRenderFrameHeight(props.htmlRender, width, contentHeight);
4747
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+
};
5855
// A cached URL with life left is reused, so the browser's cache serves the
5956
// page again; one near expiry is minted afresh, since a frame cannot report a
6057
// failed load.
6158
const [src, setSrc] = useState<string | null>(null);
6259
const srcExpiresAt = useRef(0);
6360
const [expandedSrc, setExpandedSrc] = useState<string | null>(null);
6461
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) => {
6764
setContentHeight(contentHeight);
6865
setReady(true);
69-
}, []);
66+
};
7067
const { onFullscreenChange } = props;
7168
useEffect(() => {
7269
if (expandedSrc === null) return;

0 commit comments

Comments
 (0)