blog-fs/components/switch-theme.tsx

11 lines
290 B
TypeScript
Raw Permalink Normal View History

2021-05-02 20:04:54 +08:00
import { useTheme } from "../commons/theme";
export const SwitchTheme = () => {
const { setMode, mode } = useTheme();
if (mode === "light") {
return <button onClick={() => setMode("dark")}></button>;
}
return <button onClick={() => setMode("light")}></button>;
};