Skip to content
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(core): Bail out of atom.write when atom update and current value are equal #878

Merged
merged 2 commits into from
Dec 7, 2021

Conversation

Thisen
Copy link
Collaborator

@Thisen Thisen commented Dec 7, 2021

Fixes #877.

@vercel
Copy link

vercel bot commented Dec 7, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pmndrs/jotai/4uTjLF441ENN7W5dE37GdVxYLATU
✅ Preview: https://jotai-git-fix-handle-dependencies-in-derived-chains-pmndrs.vercel.app

@Thisen Thisen requested a review from dai-shi December 7, 2021 21:02
@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 7, 2021

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.

Latest deployment of this branch, based on commit 45e60f6:

Sandbox Source
React Configuration
React Typescript Configuration
React Browserify Configuration
React Snowpack Configuration
Next.js Configuration
Next.js with custom Babel config Configuration
React with custom Babel config Configuration
jotai-demo (forked) Issue #877
jotai-demo (forked) Issue #877

@github-actions
Copy link

github-actions bot commented Dec 7, 2021

Size Change: +39 B (0%)

Total Size: 41.7 kB

Filename Size Change
dist/esm/index.js 4.41 kB +20 B (0%)
dist/index.js 5.25 kB +19 B (0%)
ℹ️ View Unchanged
Filename Size
dist/babel/plugin-debug-label.js 794 B
dist/babel/plugin-react-refresh.js 947 B
dist/babel/preset.js 1.21 kB
dist/devtools.js 1.73 kB
dist/esm/babel/plugin-debug-label.js 622 B
dist/esm/babel/plugin-react-refresh.js 763 B
dist/esm/babel/preset.js 1.01 kB
dist/esm/devtools.js 1.58 kB
dist/esm/immer.js 597 B
dist/esm/optics.js 644 B
dist/esm/query.js 1.25 kB
dist/esm/redux.js 251 B
dist/esm/urql.js 1.49 kB
dist/esm/utils.js 4.49 kB
dist/esm/valtio.js 526 B
dist/esm/xstate.js 1.13 kB
dist/esm/zustand.js 284 B
dist/immer.js 732 B
dist/optics.js 938 B
dist/query.js 1.36 kB
dist/redux.js 314 B
dist/urql.js 1.54 kB
dist/utils.js 5.72 kB
dist/valtio.js 586 B
dist/xstate.js 1.19 kB
dist/zustand.js 344 B

compressed-size-action

Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!!!
So, setAtomPromiseOrValue bails out for non-promise values, but we are invoking invalidateDependents anyway, which causes this behavior. This is partly my intention, but overlooked the reported behavior.

src/core/store.ts Outdated Show resolved Hide resolved
Copy link
Member

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again for this! This is new to me and motivates me to investigate some more, because I feel like having some other bugs. I will try.

@dai-shi dai-shi added this to the v1.4.7 milestone Dec 7, 2021
@dai-shi dai-shi merged commit fb6a0e1 into main Dec 7, 2021
@dai-shi dai-shi deleted the fix/handle-dependencies-in-derived-chains branch December 7, 2021 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[core] dependency tracking fails with derived chains
2 participants