import { useEffect, useState, memo } from "react"; import { useTheme } from "next-themes"; import { SunIcon, MoonIcon } from "../Icons"; import styles from "./ThemeToggle.module.css"; export type ThemeToggleProps = { className?: string; }; const ThemeToggle = ({ className }: ThemeToggleProps) => { const [mounted, setMounted] = useState(false); const { resolvedTheme, setTheme } = useTheme(); // render a dummy button until we're fully mounted and self-aware useEffect(() => setMounted(true), []); if (!mounted) { return ( ); } return ( ); }; export default memo(ThemeToggle);