-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: bump up jotai-effect version to v2 #10262
base: canary
Are you sure you want to change the base?
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## canary #10262 +/- ##
=======================================
Coverage 54.21% 54.21%
=======================================
Files 2332 2332
Lines 107675 107675
Branches 17799 17799
=======================================
Hits 58377 58377
- Misses 47964 47971 +7
+ Partials 1334 1327 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
This PR contains the following updates:
^1.0.5
->^2.0.0
Release Notes
jotaijs/jotai-effect (jotai-effect)
v2.0.1
Compare Source
v2.0.0
Compare Source
We’re excited to announce the release of jotai-effect v2, which brings a single but significant change to the core API:
atomEffect
now runs synchronously whenever it mounts or its dependencies change. This update improves consistency, helps avoid race conditions, and keeps related state changes in sync.What’s New?
Synchronous
atomEffect
atomEffect
would run asynchronously in the next microtask.atomEffect
runs synchronously on mount and whenever the dependencies it uses have changed.Example:
When
someAtom
is updated, the effect runs immediately, updatinganotherAtom
in the same turn. If you update multiple atoms in the same writable atom, these changes are batched together, andatomEffect
runs after those updates complete.Migration Guide
For most users, no change is required. If you depended on the old microtask delay or cross-atom batching, read on.
1. Adding back the microtask delay
If your logic explicitly relied on
atomEffect
running in a separate microtask, you can reintroduce the delay yourself:Before (v1)
After (v2)
2. Batching updates
In v1, updates to separate atoms were implicitly batched in the next microtask. In v2, batching only occurs within a single writable atom update:
Before (v1)
After (v2)
A Special Thanks to Daishi Kato
I’d like to extend my deepest gratitude to Daishi Kato, author of Jotai. Daishi dedicated months of tireless work to rework and rewrite significant parts of the Jotai core—primarily to empower community library authors such as myself to implement features such as synchronous effects in jotai-effect. His willingness to refine Jotai’s internals and his thoughtfulness in API design made this effort possible. Thank you.
Final Thoughts
We hope these improvements make your state management more predictable and easier to reason about. If you have any issues, please feel free to open a GitHub Discussion. Happy coding!
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
🔕 Ignore: Close this PR and you won't be reminded about this update again.
This PR was generated by Mend Renovate. View the repository job log.