Hybrid in and out of content usage #2810
Replies: 5 comments
-
@Morgandri1 you could use |
Beta Was this translation helpful? Give feedback.
-
Hey dbritto, |
Beta Was this translation helpful? Give feedback.
-
@Morgandri1 would you mind sharing us a minimal repro on stackblitz? |
Beta Was this translation helpful? Give feedback.
-
To be honest, I'm not sure how to replicate the functionality without the full repo, but I can add some detail: I have 2 stores created with createStore; one Client context which stores my Client class instance which interacts with the server over websocket, blah blah blah. This context is working as expected. However, when trying to use my Cache store by using |
Beta Was this translation helpful? Give feedback.
-
@Morgandri1 that's totally expected, you can't use const someStore = createStore(...)
// Inside of a React components/hooks
const SomeComponent = () => {
const someFunction = useStore(someStore, (state) => state.someFunction)
}
// Outside of React components/hooks
const { someFunction } = someStore.getState() |
Beta Was this translation helpful? Give feedback.
-
Hello!
I'm using react zustand v5, and i'm running into some issues with accessing my store outside of component content. The standard react 'no hook usage outside of component functions' error and all that jazz. My understanding from previous issues is that there isnt a great way to interop the two... any pointers for v5?
Beta Was this translation helpful? Give feedback.
All reactions