Nesting slices contextualize setters #2487
-
Hi I've been delving into Zustand over the past week, and I've had a blast figuring out how things are done. I like it a lot so far :) I'm using Zustand for UI state management, and i'm using nested objects to 'group' settings. I've run into an issue where i want to 'nest' slices, however I'm unable to find anyone who's done something similar, and while I can make slices part of a store, I've not figured out how to make a slice part of another slice without destructuring all the slices like so:
However, this unwraps all getters and setters into the same object, which is not what i want. Current non-working code example looks like so:
Comment in the last const is where my logic breaks. However, I'm not sure this is even something I'm supposed to? Because in my mind if I use 'setDogHouse' won't I lose all 'setters' in the doghouse object, as the 'newDogHouse' parameter is of type 'Doghose', which does not contain the setters? Some input would be greatly appreciated, should i separate this into several stores?, or accept that I have slices being destructured into the root object? Thanks in advance and have a great weekend! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Does #1538 help? I think it would be nice to have a guide for "namespacing" and recommend some third party libraries. |
Beta Was this translation helpful? Give feedback.
Does #1538 help?
I think it would be nice to have a guide for "namespacing" and recommend some third party libraries.
zustand-lens
is only the one available? #884 might be something.cc @dbritto-dev