From 8aa624e0dc459f82d58948eda745f2b5641d8bd0 Mon Sep 17 00:00:00 2001 From: Eric Ciarla Date: Mon, 27 May 2024 17:08:18 -0400 Subject: [PATCH] Fix window error --- src/app/layout.tsx | 6 ++++++ src/app/page.tsx | 6 ++++++ src/components/data-input.tsx | 6 ++++++ src/components/menu.tsx | 7 ++++++- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 39a0170..b7c2a63 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -3,6 +3,7 @@ import { Inter } from "next/font/google"; import "./globals.css"; import { Toaster } from "sonner"; import { Analytics } from "@vercel/analytics/react"; +import { useEffect, useState } from "react"; const inter = Inter({ subsets: ["latin"] }); export const metadata: Metadata = { @@ -15,6 +16,11 @@ export default function RootLayout({ }: Readonly<{ children: React.ReactNode; }>) { + const [isClient, setIsClient] = useState(false); + + useEffect(() => { + setIsClient(true); + }, []); return ( {children} diff --git a/src/app/page.tsx b/src/app/page.tsx index 3028cd8..1a687f2 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -2,6 +2,7 @@ import MainComponent from "@/components/main"; import { useGithubStars } from "./hooks/useGithubStars"; import GithubButton from "@/components/github-button"; +import { useEffect, useState } from "react"; /** * The issue in the original code is that the `allThemes["firecrawl"]` object does not match the expected `Theme` type. @@ -9,6 +10,11 @@ import GithubButton from "@/components/github-button"; */ export default async function Home() { + const [isClient, setIsClient] = useState(false); + + useEffect(() => { + setIsClient(true); + }, []); const githubStars = await useGithubStars(); return (
diff --git a/src/components/data-input.tsx b/src/components/data-input.tsx index 83a36cd..a060a5c 100644 --- a/src/components/data-input.tsx +++ b/src/components/data-input.tsx @@ -10,6 +10,7 @@ import { import { Button } from "./ui/button"; import { Input } from "./ui/input"; import { Textarea } from "./ui/textarea"; +import { useEffect, useState } from "react"; type DataInputProps = { setChartData: any; @@ -40,6 +41,11 @@ export default function DataInput({ pastedCsvData, setPastedCsvData, }: DataInputProps) { + const [isClient, setIsClient] = useState(false); + + useEffect(() => { + setIsClient(true); + }, []); return (
void; }) { + const [isClient, setIsClient] = useState(false); + + useEffect(() => { + setIsClient(true); + }, []); const generateEmbedCode = () => { const embedCode = `