我正在尝试从下面的链接中实现使用Typescript动态加载reducer的方法。有人可以建议一种访问商店的方法,并调用商店的自定义方法来注入reducer。
https://tylergaw.com/articles/dynamic-redux-reducers/
这是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 };
我如何在这里访问商店。 context.store是未定义的。