I have a HOC like this
const asyncComponent = (importComponent) => {
class WrapComp extends React.Component{
state = {
component: null
}
componentDidMount(){
importComponent().then(cmp => {
this.setState({component: cmp.default});
});
}
render(){
const {forwardedRef, ...rest} = this.props
C = this.state.component;
return C ? <C ref={forwardedRef} {...rest} /> : null;
}
}
return React.forwardRef((props, ref) => {
return <WrapComp {...props} forwardedRef={ref} />;
});
}
const component = asyncComponent(() => import('./another.js'))
as you can see, because the importComponent is dynamic imported, I cant use this package before the HOC return
I have a HOC like this
as you can see, because the importComponent is dynamic imported, I cant use this package before the HOC return