-
-
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
feat: jotai/valtio #405
feat: jotai/valtio #405
Conversation
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 bca497e:
|
It's fun that you can do this, but it seems somewhat odd aswell. What's the benefits over using Immer integration? I'm scared about the added confusion as well. |
Immer integration is just for updating atom values. This is to sync a value outside React.
Any idea to mitigate it? |
I was comparing them on an impl level (proxies). If you want to introduce sync to values outside React, I think we should consider adding another primitive than Valtio. I'm scared about how it will affect adoption, because of search engines. People will need to read the docs to understand how to use Valtio inside Jotai. I believe we should consider adding a primitive for syncing outside React using proxies. We can borrow ideas from Valtio. Just my two cents. |
Hope to have a better idea in docs. If it's too confusing to many people, I might consider releasing it as a 3rd-party package. |
I agree. While it may make sense from a development perspective to use the already complete Perhaps the new bundle should be called It may also seem odd to introduce a second state management library as an extra dependency in a project that already has another state management library for the purpose of supporting a single feature in the original state management library. Perhaps the I think these changes would address everyone's concerns: no confusion for Jotai users, no duplicated code for Jotai contributors. 😀 |
two out of two is not many, but feels strong opinion. let me note, this is almost analogous to jotai/xstate. xstate is a state management library.
In terms of the goal, jotai/valtio is more close to jotai/query. |
As @sandren said, jotai/proxy would make more sense. Then the impl can be inspired by Valtio. |
Note two things: a) it's not easy to create the same feature as valtio, and if I were to do it, it would be the same code. b) if it doesn't depend on valtio, it can just be in jotai/utils. Anyway, it's not requested by anybody, and my goal is to connect with valtio which already has a clean api, so 3rd-party lib would be the way to go. |
The use case would be for any project that needs read/write access to Jotai state outside of React. I think once people understand that, they will see many "valid" use cases for adding Valtio as an additional dependency to an existing React + Jotai codebase. 😀 |
Just my 2 cents: I am a huge fan of how jotai has these various integrations with other libs: Around the confusion, imo it's totally a problem of education more than implementation. |
Let's reopen it to have some more discussions. Pinning @Aslemammad to get some opinions. |
One other thing -- I think it's really easy to say "people could be confused by this" but I think a better indicator is if folks make issues saying "i am confused by this." It's easy to over optimize for a problem that doesn't exist yet. |
After I read @dai-shi's comment explaining the reasoning behind the If people can understand In general I think the risk of a few people being confused at first is not worth abandoning what could turn out to be a really amazing feature. I'm happy to see the PR re-opened under the original name of |
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/pmndrs/jotai/913E86TjUaog8NbJRyPXFyXL6cjp |
Merging this as we want to move forward. Our discussions here are valuable. Suggestions to improve docs are always welcome. |
This add a new bundle
jotai/valtio
withatomWithProxy
.