-
-
Notifications
You must be signed in to change notification settings - Fork 649
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
fix: onMount setSelf does not notify listeners #2815
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
|
Playground | Link |
---|---|
React demo | https://livecodes.io?x=id/G9F8W7YR5 |
See documentations for usage instructions.
6d4221c
to
371a9bf
Compare
371a9bf
to
57f6583
Compare
57f6583
to
97285c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good. This is something I missed it.
The test is reasonable and the fix is surprisingly simple.
Related Bug Reports or Discussions
onMount setSelf does not notify listeners (#2810)
Why aren't listeners called when calling setAtom in onMount?
Because the listener is added only after flushPending is called.
Fix: swap the order of flush pending and listeners.add(listener).
Why aren't listeners called when calling setAtom in onUnmount?
Because the listener is deleted before flushPending is called.
There's a logic cycle here:
👉 NOTE: This is expected behavior.
Check List
pnpm run prettier
for formatting code and docs