state
-
Recoil 로 Global state management 글로벌 상태관리를 해보자!React/Recoil 2023. 3. 6. 18:44
🌈 다크모드와 라이트모드 전환을 위한 state 설정을 위해 recoil을 이용해보자 📌 recoil 설치방법 npm install recoil 📌 atoms.ts import { atom } from "recoil"; export const isDarkAtom = atom({ key: "isDark", default: false, }); 📌 App.tsx useRecoilValue(isDarkAtom) 을 통해 초기값인 false 를 가져올 수 있다. import { isDarkAtom } from "./recoil/atoms"; import {useRecoilValue} from "recoil" ...(중략) function App() { const isDark = useRecoilValue(isDa..