Skip to content

how can I use this package to extract atrributes of dynamic import react component #105

Description

@boswellgao

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions