'fix' hydration error by rendering on the client
This commit is contained in:
@@ -17,6 +17,17 @@ type ThemeIconProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ThemeIcon = ({ theme }: ThemeIconProps) => {
|
const ThemeIcon = ({ theme }: ThemeIconProps) => {
|
||||||
|
|
||||||
|
const [mounted, setMounted] = React.useState(false)
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
setMounted(true)
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
if (!mounted) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
switch (theme) {
|
switch (theme) {
|
||||||
case "light":
|
case "light":
|
||||||
return (
|
return (
|
||||||
@@ -28,7 +39,7 @@ const ThemeIcon = ({ theme }: ThemeIconProps) => {
|
|||||||
)
|
)
|
||||||
case "system":
|
case "system":
|
||||||
return (
|
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:
|
default:
|
||||||
return (<>
|
return (<>
|
||||||
|
|||||||
Reference in New Issue
Block a user