0

I am trying to implement the approach from the link below for the dynamic loading of the reducers using typescript. Can someone please suggest a way to access the store and call the store's custom method to inject the reducer.

https://tylergaw.com/articles/dynamic-redux-reducers/

This is the conversion of the withReducer

const withReducer = (key:any, reducer:any) => (WrappedComponent:any) => {
   const Extended: React.FunctionComponent<any> = (props, context) => {
      context.store.injectReducer(key, reducer)
      return <WrappedComponent {...props} />
   };

   Extended.contextTypes = {
      store: object
   };

    return Extended;
};

export { withReducer };

How can I get access to the store here. The context.store is undefined.

Ace
  • 700
  • 7
  • 37

1 Answers1

0

Looks like the above approach is no longer supporter in react-redux v6.0.0. Here is another approach.

Ace
  • 700
  • 7
  • 37