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

Atoms not working with Jotai v2.9 (new store implementation) #41

Closed
rothsandro opened this issue Jul 10, 2024 · 5 comments
Closed

Atoms not working with Jotai v2.9 (new store implementation) #41

rothsandro opened this issue Jul 10, 2024 · 5 comments

Comments

@rothsandro
Copy link

Jotai Scope doesn't work with Jotai v2.9 (which introduced the new store implementation).
A non-scoped atom used inside a Jotai Scope Provider receives the default value, not the latest value.

Reproduction

Repro: https://stackblitz.com/edit/vitejs-vite-8ilg8j?file=src%2FApp.tsx&terminal=dev

The first component is rendered inside a scope provider, the other two components are rendered outside. All of them use the same non-scoped atom.

If you enter a value into the first field, all three inputs should have the same value and display the same value. But only the 2nd + 3rd components render the latest value, the first component doesn't render a value.

@dmaskasky
Copy link
Member

Acknowledged. This issue will be resolved with the rewrite I'm working on based off of the new jotai store api pmndrs/jotai#2652.

@dmaskasky
Copy link
Member

dmaskasky commented Jul 12, 2024

Ok, this is a weird one. I confirmed this is indeed a bug, however if I add the exact same code locally to codesandbox it works?

The only difference is import { Scope Provider } from 'jotai-scope' vs import { ScopeProvider } from './jotai-scope'.

I added tests to try to reproduce but they pass. #43

I'm so confused.

https://codesandbox.io/p/sandbox/atom-with-observable-infinite-mount-bug-fix-forked-253y84

@dmaskasky
Copy link
Member

Well, this is embarrassing...

Back in May I did a full rewrite of jotai-scope to support a whole slew of edge-cases including support derived atoms. It was a full ground-up rewrite of jotai-scope. I also added a ton of tests to support all conceivable edge-cases.
But it NEVER GOT DEPLOYED 😱 ...

This is why jotai-scope main works but jotai-scope@0.6.0 does not.

I'll deploy now, and this will solve this issue.

@dmaskasky
Copy link
Member

dmaskasky commented Jul 12, 2024

v0.7.0 is released and is working. 🥳
https://stackblitz.com/edit/vitejs-vite-6qcwnz?file=package.json

@rothsandro
Copy link
Author

Yeah, thanks a lot 🙏

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

No branches or pull requests

2 participants