diff --git a/components/ThemeSwitcher.tsx b/components/ThemeSwitcher.tsx index c78bd72..6314afa 100644 --- a/components/ThemeSwitcher.tsx +++ b/components/ThemeSwitcher.tsx @@ -2,12 +2,22 @@ import { MdBrightness2, MdCircle } from "react-icons/md"; import useDarkMode from "@/hooks/useDarkMode"; +import { useEffect, useState} from 'react' // TODO write tests for light/mode // TODO fix TS error on setTheme const ThemeSwitcher = () => { + const [mounted, setMounted] = useState(false); const [colorTheme, setTheme] = useDarkMode(); + useEffect(() => { + setMounted(true); + }, []); + + if(!mounted) { + return null; + } + return (
{colorTheme === "light" ? (