fix: external warning

This commit is contained in:
AykutSarac 2023-07-18 16:30:36 +03:00
parent 00f2704190
commit 01762ea804
No known key found for this signature in database

View File

@ -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 ExternalMode = () => {
const [isExternal, setExternal] = React.useState(false);
const [isOpen, setOpen] = 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); const closeModal = () => setOpen(false);
if (isExternal) return null;
return ( return (
<StyledAlert> <StyledAlert>
<Button <Button