Giter VIP home page Giter VIP logo

Comments (9)

karlpetersson avatar karlpetersson commented on May 5, 2024

Downgrading to 2.2.1 seems to fix this issue. Tested by downgrading the zustand package in the above codesandbox.

from zustand.

karlpetersson avatar karlpetersson commented on May 5, 2024

Dug in a little and it seems that subscribers are indeed being overwritten like in #84, in this case the child gets assigned same index as its parent.

What about compressing the subscribers array right after adding a subscriber? This seems to solve this issue as well as work with #84, while keeping order/indices intact. E.g: Below does not work as is.

const subscribe: Subscribe<TState> = <StateSlice>(
    subscriber: Subscriber<TState, StateSlice>
  ) => {
    // ...
    subscribers[subscriber.index] = subscriber;

    subscriberCount = 0;
    subscribers = subscribers.filter(s => {
      subscriber.index = subscriberCount++;
      return true;
    });

    return () => delete subscribers[subscriber.index];
  };

from zustand.

Jamikk avatar Jamikk commented on May 5, 2024

I have the same problem

from zustand.

fzkirablackwhy avatar fzkirablackwhy commented on May 5, 2024

me too

from zustand.

lolk12 avatar lolk12 commented on May 5, 2024

me too! HELP ZUSTAND TEAM

from zustand.

dentrado avatar dentrado commented on May 5, 2024

Any news on this? Seems to still be a problem

from zustand.

lolk12 avatar lolk12 commented on May 5, 2024

@dentrado On version 2.2.1, everything is fine

from zustand.

dentrado avatar dentrado commented on May 5, 2024

But then I get the bug they fixed in 2.2.2 instead

from zustand.

lolk12 avatar lolk12 commented on May 5, 2024

@dentrado very sadly (

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.