Giter VIP home page Giter VIP logo

Comments (4)

drcmda avatar drcmda commented on May 5, 2024 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.

alidcast avatar alidcast commented on May 5, 2024

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.

JeremyRH avatar JeremyRH commented on May 5, 2024

@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.

dai-shi avatar dai-shi commented on May 5, 2024

Closing this as it's stale. Please file a new issue for further discussion.

from zustand.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.