Skip to content

Releases: pmndrs/jotai

v1.4.6

30 Nov 12:18
Compare
Choose a tag to compare

This includes some small changes. The loadable util is re-implemented. unstable_promise in write getter becomes an option.

What's Changed

Full Changelog: v1.4.5...v1.4.6

v1.4.5

24 Nov 11:46
Compare
Choose a tag to compare

This fixes a small issue in core and a type issue in utils.

What's Changed

  • fix(utils): Unwrap loadable/selectAtom promise types by @Pinpickle in #844
  • fix(core): sync jotai renders with useState renders (#827) by @Aslemammad in #841
  • fix(core): improve read-only atom error message by @dai-shi in #845

Full Changelog: v1.4.4...v1.4.5

v1.4.4

19 Nov 09:36
Compare
Choose a tag to compare

This fixes a fundamental bug in core, which may affect some cases with complex derived atoms.

What's Changed

  • refactor(types): enable exactOptionalPropertyTypes by @dai-shi in #839
  • fix(core): mount self atom before mounting dependencies by @Thisen in #818

New Contributors

Full Changelog: v1.4.3...v1.4.4

v1.4.3

07 Nov 12:54
Compare
Choose a tag to compare

Now, useAtomDevtools in jotai/devtools supports read-only atoms. You can only see the read-only atom values in Redux DevTools Extention (you can't change the value, like with time-traveling.)

What's Changed

  • feat(devtools): read-only atom support in useAtomDevtools by @Aslemammad in #817
  • fix(core): interruptable promise handling by @dai-shi in #820
  • refactor(core): improve invalidated revision by @dai-shi in #821

New Contributors

Full Changelog: v1.4.2...v1.4.3

v1.4.2

25 Oct 11:21
Compare
Choose a tag to compare

Summary

v1.4.1 has a bug in atomWithStorage types in jotai/utils, which is fixed in v1.4.2.

What's Changed

  • fix(utils): add missing function overload for atomWithStorage by @dai-shi in #798
  • refactor(core): revert old dependencies in atom state by @dai-shi in #799
  • fix(build): resolve missing babel d.ts files by @dai-shi in #800

Full Changelog: v1.4.1...v1.4.2

v1.4.1

23 Oct 12:59
Compare
Choose a tag to compare

Summary

This adds a new experimental support for React Refresh. It has some other small fixes and improvements.

What's Changed

  • feat(babel): React Refresh support by @Thisen in #782
  • fix(utils): improve atomWithStorage types by @dai-shi in #784
  • fix(valtio): length of array didn't update (#785) by @Mingx94 in #786
  • refactor(core): retain old dependencies in atom state by @dai-shi in #793

New Contributors

Full Changelog: v1.4.0...v1.4.1

v1.4.0

14 Oct 12:31
Compare
Choose a tag to compare

Atom types are improved (BREAKING CHANGE in types)

Previously, sync atom and async atom are not distinguishable by types. This is improved now. If you make types inferred, there would be no changes required. If you explicitly type async atoms, migration would be required.

Migration Guide

Async writable atom

Previously, when you annotate atom() to create a writable atom, it looks like this:

const atom1 = atom(0)
const atom2 = atom<number, number>(
  (get) => get(atom1), 
  async (get, set, arg) => set(atom1, arg),
)

☝️ That will be type error.

A fix would be adding the 3rd type arg:

const atom2 = atom<number, number, Promise<void>>(
  (get) => get(atom1), 
  async (get, set, arg) => set(atom1, arg),
)

But, the recommendation is not to annotate atom() types, but arg only:

const atom2 = atom(
  (get) => get(atom1), 
  async (get, set, arg: number) => set(atom1, arg),
)

Async atom (read function)

Previously, async (read) atoms are typed like this:

const atom3 = atom<number>(async (get) => get(atom1))

☝️ That will not work.

A fix would be annotate it with Promsie<Value>:

const atom3 = atom<Promise<number>>(async (get) => get(atom1))

But, the recommendation is not to annotate atom() types, but to infer types:

const atom3 = atom(async (get) => get(atom1))

Async write atoms no longer suspend (BREAKING CHANGE in behavior)

Suspending on write turns out to be a bit of trouble. We should use promises.
If you depend on this behavior, you might need to do something.

Migration Guide

Previously, an async write atom suspends (triggers Suspense fallback):

const atom1 = atom(null, async (get, set, arg) => {
  // async task
})

☝️ That will not suspend any longer.

We should instead have a loading flag.

const pendingAtom = atom(false)
const atom1 = atom(null, async (get, set, arg) => {
  set(pendingAtom, true)
  // async task
  set(pendingAtom, false) // or put in finally clause
})

What's Changed

  • breaking(types): refine atom type and other types by @dai-shi in #713
  • fix(core): no async write suspense (BREAKING CHANGE in behavior) by @dai-shi in #731
  • breaking(utils): remove deprecated signature of atomWithHash by @dai-shi in #763
  • fix(utils): resolve undefined observable by @dai-shi in #777

New Contributors

Full Changelog: v1.3.9...v1.4.0

v1.3.9

10 Oct 13:01
Compare
Choose a tag to compare

Summary

There was an edge-case issue with async atoms reported #751, which is fixed. Other changes are basically refactoring, but they may fix some potential bugs.

What's Changed

  • fix(core): resolve infinite loop with chained async dependencies by @dai-shi in #766
  • fix(query): improve atomWith(Infinite)Query with enabled by @dai-shi in #767
  • fix(core): improve reading atom state by @dai-shi in #768
  • fix(core): promise handling in store by @dai-shi in #769

Full Changelog: v1.3.8...v1.3.9

v1.3.8

07 Oct 11:06
Compare
Choose a tag to compare

Summary

jotai/utils

  • atomWithHash takes options object for more customization
    • the old signature (serialize/deserialize functions) is deprecated and will be remove in the next version

jotai/valtio

  • atomWithProxy takes options object for enable sync option

PRs

  • #752 fix(valtio): Add option for atomWithProxy to be synchronous
  • #758 fix(utils): atomWithHash options

v1.3.7

01 Oct 14:13
Compare
Choose a tag to compare

Summary

v1.3.4-1.3.6 accidentally requires newer node.js versions. v1.3.7 fixes it by reverting exports format.
This also fixes handling async atoms with chained dependency, which solves some cases.

PRs

  • #734 refactor(utils): loadable util
  • #735 refactor(core): commitAtom in store
  • #747 fix(core): resume from suspense on derived atom with async atom dependency
  • #748 fix(package): avoid subpath pattern in exports