Jotai
関連パッケージ
思想・背景
基本
primitive atoms
code:javascript
import { atom } from "jotai"
const countAtom = atom(0)
const messageAtom = atom("foobar")
derived atoms
code:javascript
const someReadonlyAtomAtom = atom((get) => get(countAtom) + 1)
const readableAndWritableAtom = atom(
(get) => get(countAtom) * 3,
(get, set, newCount) => {
set(countAtom, newCount)
}
)
atomの値を読み込む
code:javascript
参考