frodare / addon-redux

Storybook addon that aids in running redux backed components in your stories.
MIT License
51 stars 17 forks source link

Example usage with @reduxjs/toolkit #19

Closed SebastienGllmt closed 3 years ago

SebastienGllmt commented 3 years ago

Redux Toolkit exposes its own utility function for creating stores called configureStore. When using this function, you need to pass all enhancers in as an array.

The type that Redux Tookit expects is StoreEnhancer[] | (StoreEnhancer[] => StoreEnhancer[])

This worked well with the v1 version of addon-redux. However, the type of withReduxEnhancer in v2 now uses

(createStore: StoreCreator) => (reducer: Reducer, state: State, enhancer: StoreEnhancer) 

which isn't compatible with Redux Toolkit.

Would be great to see an example of how to setup this library with Redux Toolkit given how prevalent that library is.

frodare commented 3 years ago

I will look into it. I don't remember changing the structure of the enhancer, so I am guessing this is caused by incorrect typing that got added when converting it to typescript.

frodare commented 3 years ago

I just published v2.0.5 which should have updated typing for the enhancer. I am new to Typescript however, and had some trouble understanding the Redux types. Please give it a shot and let me know if it now allows you to use it redux-toolkit.

SebastienGllmt commented 3 years ago

Yep, 2.0.5 no longer gives a type error 👍