Replies: 7 comments 27 replies
-
The use of the initial object is more reasonable I believe since deepClones may be unexpected for some users and they may not prefer it! While for the rest, using the initial object is not something unexpected and weird! So big up for this one. Thank you. |
Beta Was this translation helpful? Give feedback.
-
why not offer option for proxy |
Beta Was this translation helpful? Give feedback.
-
I think your solution is nearly as nice taking advantage of React's
|
Beta Was this translation helpful? Give feedback.
-
#810 is work in progress. |
Beta Was this translation helpful? Give feedback.
-
I suggest customizing promises so that users can choose between two common types of state handling.
What do you think about this? |
Beta Was this translation helpful? Give feedback.
-
I just wanted to express my immense appreciation for the outstanding work you've done with Valtio Version 1. It's so seamless that I often forget I'm using an external library. |
Beta Was this translation helpful? Give feedback.
-
#810 is merged. |
Beta Was this translation helpful? Give feedback.
-
(This description will be updated over time. Please quote sentences when you add comments.)
Why do we need v2?
When we released v1, we had some assumption about supporting suspense.
However, as the use RFC implies, the assumption wasn't correct. (The library can't throw promises internally without hooks.)
We need a new breaking API to follow the proposed way.
When will v2 be released?
It will be after the RFC is finalized. We may prepare some pre-releases.
(If it takes too long for the RFC to be finalized, we will re-consider.)
What will be breaking?
Unfortunately, APIs are not fully compatible with v1. (Some existing tests will fail.)
In v2, Valtio doesn't resolve promises, and users have to explicitly use
use
to unwrap promises.What are other changes?
React version
v2 will require at least React 18.
This will allow to drop
use-sync-external-store
package.#698 (comment)
Use of initial object (copying behavior in v1)
v1 copies initial object that is passed to
proxy()
(even internally).This is a big design decision to avoid confusion. It has been working well for most cases.
But, some people reported edge cases that the copying behavior is more confusing.
As this behavior is really hard to disable, we make it opt-in in v2.
To get the same behavior in v2:
But, that's a rare case. Unless you re-use the initial object, which is not recommended (the strong recommendation is to throw it right away), you don't need
deepClone
.Deprecated features
All features marked as deprecated in v1 will be removed in v2.
Possible better snapshot cache invalidation
#712, but I'm not sure if it's resolvable.
derive-valtio
will be removed from the dependencyIt has to be manually installed.
Beta Was this translation helpful? Give feedback.
All reactions