Skip to content
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

No reaction to the .setState function #52

Open
slutske22 opened this issue Jan 15, 2024 · 1 comment
Open

No reaction to the .setState function #52

slutske22 opened this issue Jan 15, 2024 · 1 comment

Comments

@slutske22
Copy link

Hi zukeeper team,

I am not sure if this extension is still being maintained, but thank you for your hard work on making this. An extension like this is exactly what I need to make zustand a real contender with redux and redux-devtools.

One thing I notice is that zukeeper only seems to pick up changes that are created by a set function call. I.e. in the example:

const useBearStore = create(zukeeper(set) => ({
  bears: 0,
  increasePopulation: () => set((state) => ({ bears: state.bears + 1 })),
  removeAllBears: () => set({ bears: 0 }),
}));

If called, the increasePopulation or removeAllBears register in the devtools and we see the change. But another lesser known feature of a zustand store is the setState function. For example:

// in some comonent

<button onClick={() => {
  useBearStore.setState(prev => ({ bears: prev.bears + 1 }));
}}>
  Increment
</button>

This is also perfectly valid zustand code, which accomplishes the same thing as increasePopulation. While its probably less "redux-like" to set state like this (as opposed to with a named setter function), zukeeper does not register changes made to zustand state if done via the .setState call.

I'm not sure if this would be hard to implement, but its definitely on my request list and probably would be helpful to others also.

Also, I'm seeing alot of the bugs being talked about in the other issues as well. @stphnl @ctolmsted @Santi-Lorenzo @georgevaz @meg-schneider if you guys are still maintaining this, awesome, thank you. If not, it might be nice for you to archive this or mention that you're not longer maintaining it so that we issue-loggers can accept it as is or choose another tool.

Thanks again!

@funcbind
Copy link

Facing same issue. tbh, its not that useful without taking into account state changes from setState.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants