This version introduces a new feature atomWithLazy
and deprecates useReducerAtom
and freezeAtomCreator
. It also introduces an experimental store implementation in jotai/experimental
.
Migration Guide
selectAtom
selectAtom
will no longer internally unwrap promises. To migrate to the new api, use the unwrap
utility from jotai/utils
package.
// suppose we have this
const baseAtom = atom(Promise.resolve({ id: 0, name: 'test' }))
// previously selectAtom would internally unwrap promises.
const idAtom = selectAtom(
baseAtom,
({ name }) => name,
(prev, curr) => prev.id === curr.id
)
// instead, you need to import `unwrap` from 'jotai/utils' and pass the unwrapped atom
import { unwrap } from 'jotai/utils'
...
const idAtom = selectAtom(
unwrap(baseAtom),
({ name }) => name,
(prev, curr) => prev.id === curr.id
)
useReducerAtom
https://jotai.org/docs/recipes/use-reducer-atom
freezeAtomCreator
https://jotai.org/docs/guides/debugging#freezeatomcreator
What's Changed
- [BREAKING] selectAtom does not resolve promises internally by @dmaskasky in #2435
- New store implementation as
store2.ts
by @dai-shi in #2463 - feat(utils): atomWithLazy for lazily initialized primitive atoms. by @iwoplaza in #2465
- deprecate useReducerAtom by @dai-shi in #2467
- fix(babel): do not depend on path by @dai-shi in #2482
- fix(utils): improve freezeAtom and freezeAtomCreator by @backbone87 in #2476
- deprecate freezeAtomCreator by @dai-shi in #2490
New Contributors
- @frameflare made their first contribution in #2483
Full Changelog: v2.7.2...v2.8.0