'fix' hydration error by rendering on the client

This commit is contained in:
2025-08-20 11:26:42 -04:00
parent e0ff037c06
commit d8e55e85a1

View File

@@ -17,6 +17,17 @@ type ThemeIconProps = {
}
const ThemeIcon = ({ theme }: ThemeIconProps) => {
const [mounted, setMounted] = React.useState(false)
React.useEffect(() => {
setMounted(true)
}, [])
if (!mounted) {
return null
}
switch (theme) {
case "light":
return (
@@ -28,7 +39,7 @@ const ThemeIcon = ({ theme }: ThemeIconProps) => {
)
case "system":
return (
<Monitor className="absolute h-[1.2rem] w-[1.2rem] scale-100 transition-all" />
<Monitor className="absolute h-[1.2rem] w-[1.2rem] scale-100" />
)
default:
return (<>