21 lines
479 B
TypeScript
21 lines
479 B
TypeScript
"use client";
|
|
|
|
import { useAtom } from "jotai";
|
|
import { themeAtom } from "./_lib/atom";
|
|
import { useEffect } from "react";
|
|
|
|
export default function Store() {
|
|
const [theme] = useAtom(themeAtom)
|
|
|
|
useEffect(() => {
|
|
const root = document.documentElement
|
|
console.log('theme: ' + theme);
|
|
|
|
if (theme === 'dark') {
|
|
root.classList.add('dark')
|
|
} else {
|
|
root.classList.remove('dark')
|
|
}
|
|
}, [theme])
|
|
return ''
|
|
} |