Comments (4)
shallow copies have subtle but interesting properties, for instance knowing from the root up which nodes have changed till the very last atomic. i always felt like it's a very simple but powerful concept that transcends languages - and if someone wants proxies: immer.
as for tearing, i've read up on it and bumped into the following written by @markerikson
Part of the idea behind using createContext for v6 was that since React ensures a given render pass uses the same context value everywhere, there would be no chance of tearing. The v6 implementation does work, but it's not as efficient in some cases as we'd hoped. We're currently working on coming up with a different internal implementation that goes back to using direct subscriptions instead. This does potentially mean that tearing is a possibility again, but at this point we need to sit back and wait for the React team to finish putting Concurrent Mode together before we can spend time seeing what the issues really are.
i like the levelheaded approach. it's fine to go and look what the problem could be, but i think it's too early to panic.
from zustand.
came upon this repo: https://github.com/dai-shi/will-this-react-global-state-work-in-concurrent-mode
@JeremyRH looks like zustand's event emitter implementations will cause problems in concurrent mode? also, curious, is there a reason you guys decided against using context API with proxies?
from zustand.
@alidcastano Creating a deep copy of the state, storing it in a ref, and updating it in useEffect
solves the tearing issue. The problem is creating a deep copy of the state can be expensive and would have to be done in every call to the state setter or in useEffect
. The issue that has me more concerned is "check4: proper update after interrupt". I haven't figured out how to solve this without using a context provider.
from zustand.
Closing this as it's stale. Please file a new issue for further discussion.
from zustand.
Related Issues (20)
- When the set operation is executed in the 「then callback」, the 「set operation」 takes nearly a hundred times longer.
- Resetting Multiple Stores Example Doesn't Work with the Currying Required Elsewhere for Typescript Support
- 123e
- In nextjs13's app directory, how can the server components send Fetch?
- Unnecessary Renders Triggered by a Hook after Migrating to Zustand
- with immer midderware, Array type wrong HOT 2
- The reactNode is stored in the store, sometimes causing the component to lose update. HOT 1
- Is there a way to reset data when switching routes? The previous method cannot take effect#1192
- Type problem with persist HOT 3
- Reset store not working on log out
- I can't update state with new data from Tanstack Query HOT 2
- The app hanging when initializing the store with and array of objects. HOT 4
- Is there any chance to simplify types?
- How to move the router state to store?
- Website graphics rendering issues (Linux) HOT 3
- shallow not support nested object HOT 1
- Are these two methods exactly the same? HOT 1
- It’s not recommended to suspend a render based on a store value returned by useSyncExternalStore.
- RFC: How is v5-alpha? HOT 11
- should useShallow add into the documents?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zustand.