Adhere All Zustand State To a Localized Scope #2177
-
Right now I am using Zustand to keep track of all of my state in a react-three-fiber application. In the application I rollup specific components into useable modular 3D components (and web components). As designed by Zustand (I think), when components are used that share the same state, the state gets updated in both places. I want to prevent this from happening and would like each component to keep track of its own state only. Is it possible to localize the state of each individual component? I did quite bit of search for a solution on this and was not able to find a concrete answer that fits my use case. If there was a way to do this with rollup, I think that would be an even better method. Thanks ahead of time! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 24 replies
-
Not sure if I get the point, but does React Context help? |
Beta Was this translation helpful? Give feedback.
-
@dbritto-dev The CodeSandbox gives 404. |
Beta Was this translation helpful? Give feedback.
@Jonathynlee here you go -> https://codesandbox.io/p/sandbox/gifted-dan-m2f8zj?file=%2Fsrc%2FApp.tsx%3A29%2C32