Created
April 22, 2024 21:17
-
-
Save PaulieScanlon/1086928b196a9d0dd5a18db21e67bb53 to your computer and use it in GitHub Desktop.
Example of state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/state/index.ts | |
import { atom } from 'jotai'; | |
+ import { atomWithStorage } from 'jotai/utils'; | |
export const countAtom = atom(0); | |
export const objectAtom = atom({ | |
foo: 'bar', | |
test: true, | |
}); | |
export const userAtom = atom({ | |
isLoggedIn: false, | |
isAdmin: false, | |
}); | |
+ export const darkModeAtom = atomWithStorage('darkMode', false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment