Action does not work when Store is created using initProps #2189
-
|
Here is the link to sandbox |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 21 replies
-
|
@pdhruv93 here you go -> https://codesandbox.io/p/sandbox/react-zustand-init-forked-nzp4qy?file=%2Fsrc%2FApp.tsx%3A15%2C11 |
Beta Was this translation helpful? Give feedback.
-
|
@dbritto-dev Isn't there some other way to populate the store(also share the store) other than using the context? I kind of feel that using context is killing the flexibility of zustand store. I can only access the store and store state under the context provider. One way I find is to just to create an action under store to set the states to input props. But setting the states this way is causing the subscription to run |
Beta Was this translation helpful? Give feedback.
-
|
@dbritto-dev Is it possible to access the current store params from within the subscription. I would like to make a call to the api sending in all the store params. I could only get the current state of the subscribed store params |
Beta Was this translation helpful? Give feedback.
-
|
@dbritto-dev everything now works, the store is also populated. One problem: I logged this: I see following logs: |
Beta Was this translation helpful? Give feedback.
@pdhruv93 here you go -> https://codesandbox.io/p/sandbox/react-zustand-init-forked-nzp4qy?file=%2Fsrc%2FApp.tsx%3A26%2C7