Releases: pmndrs/jotai
v1.4.6
This includes some small changes. The loadable
util is re-implemented. unstable_promise
in write getter becomes an option.
What's Changed
- fix(type): improve core typing by @dai-shi in #852
- fix(core): unstable_promise option in write getter by @dai-shi in #855
- fix(utils): refactor loadable by @dai-shi in #857
- fix(urql): atomWithQuery for edge cases by @dai-shi in #856
Full Changelog: v1.4.5...v1.4.6
v1.4.5
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
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
- @zacjones93 made their first contribution in #824
Full Changelog: v1.4.3...v1.4.4
v1.4.3
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
- @steinybot made their first contribution in #804
Full Changelog: v1.4.2...v1.4.3
v1.4.2
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
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
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
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
Summary
jotai/utils
atomWithHash
takesoptions
object for more customization- the old signature (
serialize
/deserialize
functions) is deprecated and will be remove in the next version
- the old signature (
jotai/valtio
atomWithProxy
takesoptions
object for enablesync
option
PRs
v1.3.7
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.