Skip to content

Instantly share code, notes, and snippets.

@PaulieScanlon
Created April 22, 2024 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulieScanlon/1086928b196a9d0dd5a18db21e67bb53 to your computer and use it in GitHub Desktop.
Save PaulieScanlon/1086928b196a9d0dd5a18db21e67bb53 to your computer and use it in GitHub Desktop.
Example of state
// 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