Skip to content

Commit 556d563

Browse files
committed
update
1 parent 6a083b2 commit 556d563

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

app/components/artifact.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,18 @@ export function HTMLPreview(props: {
3333
*/
3434

3535
useEffect(() => {
36-
window.addEventListener("message", (e) => {
36+
const handleMessage = (e) => {
3737
const { id, height, title } = e.data;
3838
setTitle(title);
3939
if (id == frameId.current) {
4040
setIframeHeight(height);
4141
}
42-
});
43-
}, [iframeHeight]);
42+
};
43+
window.addEventListener("message", handleMessage);
44+
return () => {
45+
window.removeEventListener("message", handleMessage);
46+
};
47+
}, []);
4448

4549
const height = useMemo(() => {
4650
const parentHeight = props.height || 600;

app/components/ui-lib.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,11 +528,15 @@ export function FullScreen(props: any) {
528528
}
529529
}, []);
530530
useEffect(() => {
531-
document.addEventListener("fullscreenchange", (e) => {
531+
const handleScreenChange = (e) => {
532532
if (e.target === ref.current) {
533533
setFullScreen(!!document.fullscreenElement);
534534
}
535-
});
535+
};
536+
document.addEventListener("fullscreenchange", handleScreenChange);
537+
return () => {
538+
document.removeEventListener("fullscreenchange", handleScreenChange);
539+
};
536540
}, []);
537541
return (
538542
<div ref={ref} style={{ position: "relative" }} {...rest}>

0 commit comments

Comments
 (0)