frodare/addon-redux

Support for newer version of redux / react-redux

mfolnovic opened this issue · 6 comments

This addon works correctly on versions:

    "react-redux": "^5.1.1",
    "redux": "^3.5.2",

But, on versions:

    "react-redux": "^6.0.0",
    "redux": "^4.0.1",

I receive error:
Invariant Violation: Could not find "store" in the context of "Connect(Container)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(Container) in connect options.

Thank you for letting me know! I will look into this. I think there are some issues switching between storybook 3 and 4 too.

My team is also affected by this issue :(

This looks to be due to the updates to react-redux which starting using the new Context API in React 16.3 I think I have found a solution by requiring the Provider component from react-redux to be passed into the addon builder function for addon-redux.

This would require a change to your decorators file

import { Provider } from 'react-redux'

export const withRedux = (state, actions) => withReduxCore(addons)({
  store, state, actions, Provider
})

This seems clunky to me and I would much prefer to find a "more correct" way to fix this, if one exists. If I don't find something in the next few hours I will release a new build with these changes.

@mfolnovic @pkuczynski
I just deployed v1.0.0 of addon-redux. Can you please try it out and see if it fixes the problem. I would like to make sure it works before closing this issue. You will need to pass in the Provider now as shown above.

After upgrading to the new version of the extension all of my stories are gone (with message

No Preview

Sorry, but you either have no stories or none are selected somehow.
Please check the storybook config.
Try reloading the page.

Do I still need to do the change with Provider in decorator?

I tried with what you said and it works now! Thanks! You should updated docs, as they do not mention nothing about Provider now :)