Derived read-write: atom(get => get(baseAtom), (get, set, newVal) => set(baseAtom, newVal * 2)). atomWithStorage('key', defaultVal) từ jotai/utils tự đồng bộ localStorage, handle SSR hydration. atomWithDefault(get => get(otherAtom)) tạo atom có thể override nhưng mặc định derive.
Architecture Provider-less: Jotai dùng WeakMap lưu state theo atom object reference thay vì string key như Recoil — atoms tự nhiên unique, hỗ trợ code-split, không lo duplicate key. useAtomValue (chỉ đọc) và useSetAtom (chỉ ghi, không subscribe, không re-render) là hooks tối ưu performance.
EN
Primitive atom: const countAtom = atom(0) — use useAtom(countAtom) in a component, returns [value, setValue].
Read-write derived: atom(get => get(baseAtom), (get, set, newVal) => set(baseAtom, newVal * 2)). atomWithStorage('key', defaultVal) from jotai/utils auto-syncs to localStorage and handles SSR hydration. atomWithDefault(get => get(otherAtom)) creates an atom that can be overridden but defaults to a derived value.
Provider-less architecture: Jotai uses a WeakMap to store state keyed by atom object reference instead of a string key like Recoil — atoms are naturally unique, support code-splitting, and have no risk of duplicate key collisions. useAtomValue (read-only) and useSetAtom (write-only, no subscription, no re-render) are the performance-optimized hooks.
Xem toàn bộ State Management cùng filter theo level & chủ đề con.