fix theme toggle button
This commit is contained in:
parent
3be59f97c3
commit
a3e9411c97
@ -2,11 +2,20 @@
|
|||||||
|
|
||||||
import { MoonIcon, SunIcon } from "@heroicons/react/16/solid";
|
import { MoonIcon, SunIcon } from "@heroicons/react/16/solid";
|
||||||
import { useTheme } from "next-themes";
|
import { useTheme } from "next-themes";
|
||||||
import { ReactElement } from "react";
|
import { ReactElement, useEffect, useState } from "react";
|
||||||
|
|
||||||
export function ToggleThemeButton(): ReactElement {
|
export function ToggleThemeButton(): ReactElement {
|
||||||
|
const [mounted, setMounted] = useState(false);
|
||||||
const { theme, setTheme } = useTheme();
|
const { theme, setTheme } = useTheme();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setMounted(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
if (!mounted) {
|
||||||
|
return <></>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className="rounded-lg"
|
className="rounded-lg"
|
||||||
|
Loading…
Reference in New Issue
Block a user