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(vanilla): should recompute state after onMount #2099

Merged
merged 3 commits into from
Aug 31, 2023
Merged

fix(vanilla): should recompute state after onMount #2099

merged 3 commits into from
Aug 31, 2023

Conversation

tmkx
Copy link
Contributor

@tmkx tmkx commented Aug 29, 2023

Related Issues or Discussions

Fixes #2098

Summary

Check List

  • yarn run prettier for formatting code and docs

@vercel
Copy link

vercel bot commented Aug 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
jotai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 31, 2023 2:36am

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 29, 2023

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 4aa774d:

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
optimistic-bush-9rccdd Issue #2098

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 for working on it!

Can you add a test with store api, without atomWithStorage, and without React?

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.

The tricky thing is CI tests.

tests/react/vanilla-utils/atomWithStorage.test.tsx Outdated Show resolved Hide resolved
tests/react/vanilla-utils/atomWithStorage.test.tsx Outdated Show resolved Hide resolved
tests/react/vanilla-utils/atomWithStorage.test.tsx Outdated Show resolved Hide resolved
src/vanilla/store.ts 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.

It looks good. Nice work.

Let me try and see if I can refactor.

@dai-shi
Copy link
Member

dai-shi commented Aug 31, 2023

I guess the fundamental issue is that dependent graph isn't ready when onMount is invoked. So, the queue is introduced. Not really sure if it's the ideal solution, but it works so far.

@dai-shi dai-shi changed the title fix: should recompute state after onMount fix(vanilla): should recompute state after onMount Aug 31, 2023
@dai-shi dai-shi added this to the v2.4.1 milestone Aug 31, 2023
@dai-shi dai-shi merged commit fdd40f7 into pmndrs:main Aug 31, 2023
29 checks passed
@tmkx tmkx deleted the fix/issue-2098 branch August 31, 2023 11:06
@fturmel
Copy link

fturmel commented Aug 31, 2023

Thank you both!

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.

atomWithStorage issue since 2.3.0+
3 participants