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(utils): atomWithObservable is not resubscribed after remount #1016

Merged
merged 1 commit into from
Mar 3, 2022

Conversation

11bit
Copy link
Contributor

@11bit 11bit commented Feb 18, 2022

atomWithObservable seems to be not resubscribing to observable when a component is being hidden and then shown again.

There is a test reproducing it and also a codesandbox: atom value updates when clicking on a document, but if you hide/show component, it doesn't update anymore.

@vercel
Copy link

vercel bot commented Feb 18, 2022

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/3GesYwQmfi2h3fgC7T4Kia6nvPbB
✅ Preview: https://jotai-git-fork-11bit-bugfix-atomwithobservable-remount-pmndrs.vercel.app

@codesandbox-ci
Copy link

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 1c79a74:

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
hardcore-albattani-jc9ky1 PR

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.

Nice catch!!!
Thanks for the fix and the test!

@dai-shi
Copy link
Member

dai-shi commented Feb 18, 2022

@11bit Thanks for your contribution. If you are interested, would you like to contribute more? We need more contributors for atomWithObservable. See #875 for example.

@11bit
Copy link
Contributor Author

11bit commented Feb 19, 2022

@dai-shi sure. will have a look at the next week

@dai-shi dai-shi added this to the v1.6.1 milestone Mar 3, 2022
@dai-shi dai-shi merged commit 027f367 into pmndrs:main Mar 3, 2022
@dai-shi dai-shi changed the title Fix atomWithObservable is not resubscribed after remount fix(utils): atomWithObservable is not resubscribed after remount Mar 9, 2022
@11bit
Copy link
Contributor Author

11bit commented Mar 12, 2022

@dai-shi I made PR #1058 that adds initialData (api is similar to #875 but different implementation). Please have a look

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.

2 participants