Skip to content

Releases: pmndrs/jotai

v1.4.9

20 Dec 11:33
Compare
Choose a tag to compare

There was a regression in v1.4.7, which was in core and affected utils like atomWithStorage, jotai/xstate and maybe some others. It should be fixed. Please report issues if you find any.

What's Changed

  • fix(core): resolve infinite loop with derived atoms with onMount by @dai-shi in #900

Full Changelog: v1.4.8...v1.4.9

v1.4.8

16 Dec 13:00
Compare
Choose a tag to compare

This has some small fixes.

What's Changed

  • fix(type): Fix types on waitForAll to work with destructuring by @russelldavis in #889
  • fix(utils): atomWithStorage with async json storage by @dai-shi in #894

New Contributors

Full Changelog: v1.4.7...v1.4.8

v1.4.7

08 Dec 11:57
Compare
Choose a tag to compare

This fixes some bugs, most importantly #877.

What's Changed

  • fix(core): refactor store with suspense promise by @dai-shi in #866
  • fix(utils): fix waitForAll types by @dai-shi in #871
  • fix(core): refactor store readAtomState by @dai-shi in #872
  • fix(core): refactor store (setAtomPromiseOrValue) by @dai-shi in #873
  • fix(core): Bail out of atom.write when atom update and current value are equal by @Thisen in #878
  • fix(core): refactor atomState in store by @dai-shi in #880

New Contributors

Full Changelog: v1.4.6...v1.4.7

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