Skip to content

Releases: pmndrs/jotai

v2.4.0

23 Aug 12:46
Compare
Choose a tag to compare

This version fixes an edge case in core that has existed since v2.0.0.

What's Changed

  • fix(vanilla): should only mount dependencies if the atom is mounted by @dai-shi in #2078
  • fix(vanilla): should update with conditional dependencies by @dai-shi in #2086
  • fix(utils): Do not set a splitted atom when not actually modified by @arnodb in #2088

New Contributors

Full Changelog: v2.3.1...v2.4.0

v2.3.1

08 Aug 02:30
Compare
Choose a tag to compare

There was a bug in #2061, which is fixed. It's about a dev-only warning.

What's Changed

  • fix: global number of instances flag by @fz6m in #2066

New Contributors

Full Changelog: v2.3.0...v2.3.1

v2.3.0

07 Aug 01:52
Compare
Choose a tag to compare

Jotai v2's store API is framework-agnostic. The primary use case is for React, but the store can be used for other frameworks. One of the difficulties was handling promises, and there has been unstable_unwrap util since Jotai v2.0.0. Now, it's considered stable and becomes unwrap util (see docs for details).

What's Changed

Full Changelog: v2.2.3...v2.3.0

v2.2.3

31 Jul 03:17
Compare
Choose a tag to compare

This comes with some small improvements.

What's Changed

  • fix: declare @types/react as peerDep to avoid phantom dep by @wjw99830 in #2048
  • fix(vanilla): check duplicated instances by @dai-shi in #2049

New Contributors

Full Changelog: v2.2.2...v2.2.3

v2.2.2

05 Jul 14:42
Compare
Choose a tag to compare

This includes some fixes for edge cases.

What's Changed

  • fix(vanilla): bail out recomputing with the same value by @dai-shi in #2016
  • fix(utils): loadable handles sync errors by @dai-shi in #2021

New Contributors

Full Changelog: v2.2.1...v2.2.2

v2.2.1

19 Jun 01:51
Compare
Choose a tag to compare

This includes some improvements in jotai/utils. Especially, unstable_unwrap is getting to be stable.

What's Changed

  • feat(utils/useHydrateAtoms) - Optionally rehydrate with force hydrate by @SariSabouh in #1990
  • fix(utils): revert atomWithStorage typing by @dai-shi in #1994
  • fix(utils): improve selectAtom typing by @dai-shi in #1995
  • fix(utils): improve unstable_unwrap for sometimes async atom by @dai-shi in #1996
  • fix(utils): unstable_unwrap to support writable atom by @dai-shi in #1997

New Contributors

Full Changelog: v2.2.0...v2.2.1

v2.2.0

12 Jun 11:03
Compare
Choose a tag to compare

It includes a few improvements. Some utils are rewritten as there was a misconception when migrating from v1. ESM builds are optimized for Vite users.

Migration Guide for jotai/utils

atomWithDefault

// suppose we have this
const asyncAtom = atom(() => Promise.resolve(1))
const countAtom = atomWithDefault((get) => get(asyncAtom))
// and in component
const setCount = useSetAtom(countAtom)

// previously,
setCount((c) => c + 1) // it worked, but it will no longer work

// instead, you need to do this
setCount((countPromise) => countPromise.then((c) => c + 1))

atomWithStorage

// suppose we have async storage
const storage = createJSONStorage(() => AsyncStorage)
const countAtom = atomWithStorage('count-key', 0, storage)
  // in component
  const [count, setCount] = useAtom(countAom)

  // previously, countAtom is a sync atom, so you could update like this:
  setCount((c) => c + 1)

  // with the new version, it becomes async occasionally, so you need to resolve it:
  setCount(async (c) => (await c) + 1)

What's Changed

  • breaking(utils): predictable atomWithDefault by @dai-shi in #1939
  • breaking(utils): improve atomWithStorage by @dai-shi in #1958
  • feat(vanilla): new store listeners for devtools by @dai-shi in #1966
  • fix(build): mode env for "import" condition" by @dai-shi in #1978

New Contributors

Full Changelog: v2.1.1...v2.2.0

v2.1.1

03 Jun 15:01
Compare
Choose a tag to compare

This version fixes some issues in edge cases.

What's Changed

  • fix(vanilla): Stable promise by @backbone87 in #1933
  • fix(vanilla): update atoms with tree structure dependencies (regression from v1) by @dai-shi in #1959
  • fix: prefer PromiseLike where appropriate by @dai-shi in #1967

New Contributors

Full Changelog: v2.1.0...v2.1.1

v2.1.0

06 May 03:54
Compare
Choose a tag to compare

This includes some improvements as well as some breaking changes in unstable features.

What's Changed

  • fix(vanilla): better promise handling by @dai-shi in #1851
  • fix(atomWithStorage): handle RESET/removeItem from cross-tab storage updates by @nderscore in #1882
  • breaking(vanilla): remove deprecated store dev methods by @dai-shi in #1893
  • fix(react): Infer useHydrateAtoms value types from atom.read ReturnType by @ericdowell in #1898
  • chore(tests): migrate to vitest by @arjunvegda in #1839

New Contributors

Full Changelog: v2.0.4...v2.1.0

v2.0.4

10 Apr 03:42
Compare
Choose a tag to compare

This includes some small improvements. One of them is to improve Deno compatibility.

What's Changed

  • fix(atomWithStorage, createJSONStorage): scope subscriptions to specified browser storage by @nderscore in #1814
  • fix(babel): improve debug label support for third-party jotai libraries by @arjunvegda in #1818
  • fix(react): atom type inference in hooks by @Thisen in #1866
  • chore: add extentsion in imports by @dai-shi in #1823

New Contributors

Full Changelog: v2.0.3...v2.0.4