"use client"; import React, { useEffect, useState } from "react"; import { useTheme } from "next-themes"; import { MoonIcon, SunIcon } from "@heroicons/react/24/outline"; function Theme() { const { resolvedTheme, setTheme } = useTheme(); const [mounted, setMounted] = useState(false); const isDark = resolvedTheme === "dark"; // useEffect only runs on the client, so now we can safely show the UI useEffect(() => { setMounted(true); }, []); if (!mounted) { return null; } return (
); } export default Theme;