Zustand and Storybook #2626
Answered
by
dbritto-dev
sourire123
asked this question in
Q&A
-
Hi, is there any neat solution to mock Zustand store for particular story in Storybook? For example we can consider store with simple empty data field |
Beta Was this translation helpful? Give feedback.
Answered by
dbritto-dev
Jul 1, 2024
Replies: 1 comment 9 replies
-
@sourire123 you can use storybook decorators to do that. For instance if you are using Context API you can wrap your components with a decorator to initialize the data or you can use Ref: https://storybook.js.org/docs/writing-stories/decorators#context-for-mocking |
Beta Was this translation helpful? Give feedback.
9 replies
Answer selected by
sourire123
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@sourire123 you can use storybook decorators to do that. For instance if you are using Context API you can wrap your components with a decorator to initialize the data or you can use
useEffect
anduseYourStore.setState
to do the same.Ref: https://storybook.js.org/docs/writing-stories/decorators#context-for-mocking