should i have a sepreate slice for different part of the zustand state
Unanswered
Giant panda posted this in #help-forum
Giant pandaOP
i 'm using zustand for state in my next js app i currently have one store holding state of different parts of the application first question is there any issue with this implementation , second i wanted to edit a message in my chat app i wanted to display a input element instead of the message so the user can edit the message given my implementation here are my options 1 ) pass down a setState function to toggle an editing state requires about 2 levels of prop drilling 2 ) i can give each message in the state a property to toggle editing 3 ) create a context for the messages that has a isEditing state that can be used to toggle to an input component
1 Reply
Chum salmon
First Q:
If the "different parts" of the application are connected, then you should have them in the same Zustand store. But if they are not, eg. Cart and Blog, then you should split them.
Second Q:
Why do we prop drill when we have Zustand? With that said, I'm against option 1. Option 2 seems like a better solution for me.
If the "different parts" of the application are connected, then you should have them in the same Zustand store. But if they are not, eg. Cart and Blog, then you should split them.
Second Q:
Why do we prop drill when we have Zustand? With that said, I'm against option 1. Option 2 seems like a better solution for me.