Remove use of useEventListener in shared directory
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import useEventListener from "~/hooks/useEventListener";
|
|
||||||
import Frame, { resizeObserverScript } from "../components/Frame";
|
import Frame, { resizeObserverScript } from "../components/Frame";
|
||||||
import { EmbedProps as Props } from ".";
|
import { EmbedProps as Props } from ".";
|
||||||
|
|
||||||
@@ -14,14 +13,16 @@ function GitLabSnippet(props: Props) {
|
|||||||
"<style>body { margin: 0; .gitlab-embed-snippets { margin: 0; } }</style>";
|
"<style>body { margin: 0; .gitlab-embed-snippets { margin: 0; } }</style>";
|
||||||
const iframeHtml = `<html><head><base target="_parent">${styles}</head><body>${snippetScript}</body></html>`;
|
const iframeHtml = `<html><head><base target="_parent">${styles}</head><body>${snippetScript}</body></html>`;
|
||||||
|
|
||||||
useEventListener(
|
React.useEffect(() => {
|
||||||
"message",
|
const handler = (event: MessageEvent<{ type: string; value: number }>) => {
|
||||||
(event: MessageEvent<{ type: string; value: number }>) => {
|
|
||||||
if (event.data.type === "frame-resized") {
|
if (event.data.type === "frame-resized") {
|
||||||
setHeight(event.data.value);
|
setHeight(event.data.value);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
);
|
window.addEventListener("message", handler);
|
||||||
|
|
||||||
|
return () => window.removeEventListener("message", handler);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Frame
|
<Frame
|
||||||
|
|||||||
Reference in New Issue
Block a user