@dedrick
To change the Redux state when using Storybook, you can dispatch actions in your story to update the state. Here is an example of how you can do this:
1 2 3 4 5 6 7 8 9 10 11 12 |
import React from 'react'; import { Provider } from 'react-redux'; import { createStore } from 'redux'; import rootReducer from './reducers'; const store = createStore(rootReducer); export const withRedux = (Story) => ( <Provider store={store}> <Story /> </Provider> ); |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import { withRedux } from './decorators'; export default { title: 'MyComponent', decorators: [withRedux], }; export const Default = () => { // Dispatch an action to update the Redux state store.dispatch({ type: 'UPDATE_STATE', payload: { property: 'value' } }); return <MyComponent />; }; |
By dispatching actions in your stories, you can modify the Redux state and see the changes reflected in your components rendered by Storybook.