From 01762ea8041273f05fd60a399627618c9648c36b Mon Sep 17 00:00:00 2001 From: AykutSarac Date: Tue, 18 Jul 2023 16:30:36 +0300 Subject: [PATCH] fix: external warning --- src/layout/ExternalMode/index.tsx | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/layout/ExternalMode/index.tsx b/src/layout/ExternalMode/index.tsx index 848e77a..00408db 100644 --- a/src/layout/ExternalMode/index.tsx +++ b/src/layout/ExternalMode/index.tsx @@ -37,21 +37,22 @@ const StyledTitle = styled.div` } `; -const isExternal = () => { - if (typeof window === "undefined") return true; - - if (window.location.pathname.includes("widget")) return false; - if (window.location.host !== "jsoncrack.com") return true; - return false; -}; - const ExternalMode = () => { + const [isExternal, setExternal] = React.useState(false); const [isOpen, setOpen] = React.useState(false); - if (!isExternal()) return null; + React.useEffect(() => { + if (typeof window !== "undefined") { + if (window.location.pathname.includes("widget")) return setExternal(false); + if (window.location.host !== "jsoncrack.com") return setExternal(true); + return setExternal(false); + } + }, []); const closeModal = () => setOpen(false); + if (isExternal) return null; + return (