From a3e9411c9736243c9054cde98ed759508d3b6b6a Mon Sep 17 00:00:00 2001 From: Liam Date: Fri, 19 Apr 2024 22:37:25 +0100 Subject: [PATCH] fix theme toggle button --- src/app/components/theme-toggle-button.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/components/theme-toggle-button.tsx b/src/app/components/theme-toggle-button.tsx index 3c47059..826099b 100644 --- a/src/app/components/theme-toggle-button.tsx +++ b/src/app/components/theme-toggle-button.tsx @@ -2,11 +2,20 @@ import { MoonIcon, SunIcon } from "@heroicons/react/16/solid"; import { useTheme } from "next-themes"; -import { ReactElement } from "react"; +import { ReactElement, useEffect, useState } from "react"; export function ToggleThemeButton(): ReactElement { + const [mounted, setMounted] = useState(false); const { theme, setTheme } = useTheme(); + useEffect(() => { + setMounted(true); + }, []); + + if (!mounted) { + return <>; + } + return (