Can I initialize the store with props during rendering, i.e. using a context-provider pattern? #61
michaelschufi
started this conversation in
General
Replies: 1 comment
-
@michaelschufi - curious if you've figured out a solution for this? I feel like I'm getting close by following this documentation from zustand, however I believe a different implementation of "useStore" would be required. `export const useCounterStore = <T,>( if (!counterStoreContext) { return useStore(counterStoreContext, selector) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm looking for a similar approach as this https://docs.pmnd.rs/zustand/guides/initialize-state-with-props.
I need to initialize the store based on data from the server. In Next.js you can, for example, let the layout get some data from the server and use the Context-Provider pattern to initialize a context. (https://nextjs.org/docs/getting-started/react-essentials#using-context-in-client-components)
Beta Was this translation helpful? Give feedback.
All reactions