should i have a sepreate slice for different part of the zustand state
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
2 levels of prop drilling is nothing and it's fine. It's not something to eliminate at all costs. Either way I wouldn't do the second option that's for sure. It's not data about the message, it's a UI state so that has nothing to do with it.
Since you have only 2 levels of prop drilling the first option is simpler and good enough in your case, so I would go with it