Skip to content

v2.8.0

Latest
Compare
Choose a tag to compare
@dai-shi dai-shi released this 08 Apr 04:15
· 12 commits to main since this release

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

New Contributors

Full Changelog: v2.7.2...v2.8.0