HOC with wrapped component with asyncConnect
See original GitHub issueHi! Is it possible to make HOC which wraps asyncConnect’ed component. I can’t do this. Because all asyncItems, mapStateToProps and mapDispatchToProps of the Component seem to be dropped.
Say, I’ve got the Component:
...
const mapStateToProps = state => ({
...
});
const asyncItems = [{
key: 'myItems',
promise: ({router, store: { dispatch, getState }}) => {}
}];
const enhancer = createHOC();
module.exports = enhancer(asyncConnect(
asyncItems,
mapStateToProps,
mapDispatchToProps,
)(Component));
And HOC itself has the asyncConnect enhancer 😃 Is it possible or do I have to abandon this idea at all?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Higher-Order Components - React
A HOC is a pure function with zero side-effects. And that's it! The wrapped component receives all the props of the container, along...
Read more >How to Wrap One React Component into Another | Pluralsight
The HOC function outputs a class component with improvements we want to make, like additional lifecycle methods, API endpoints, etc. render() ...
Read more >Adding props to wrapped component with HOC - Stack Overflow
As I know, HOC will be triggered once it's initiated to render. At that time your props passed through HOC are available.
Read more >Introduction to Higher-Order Components in React by example
We have created a new component called HOC which returns the <WrappedComponent/> from its render function. While this actually adds no ...
Read more >react redux use hoc with connected component - splunktool
Is it possible to make HOC which wraps asyncConnect'ed component. I can't do this. Because all asyncItems, mapStateToProps and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
After upgrading to RR v4 and the latest version of redux-connect, I think that the solution for both data-fetching and code-splitting is about organizing you code. The route-level component can’t both be HOC’ed with redex-connect and be lazy-loaded, so you should do data-fetching in the route-level component and move lazy-loading into a child-component. Can’t think of any other way to do this, since you don’t have a getComponent function with react-router-config, without writing you own helper that both lazy-load and do data-fetching. Maybe this should be mentions in the README.md to save people from spending time looking into this?
Hi, this is an example of a controller. You just move the visuals and heavy dependencies into its own component, and just hot-load it from the controller, but keep the asyncConnect hoc on the controller so redux-connect will discover it through react-router-config