You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{render}from'react-dom';importReact,{Component}from'react';import{asyncComponent}from"react-async-component";constComp=asyncComponent({resolve: ()=>newPromise(resolve=>require.ensure([],(require)=>{resolve(require('./components/comp'));}))})// App component will render Comp after 5 secondsexportdefaultclassAppextendsComponent{constructor(props){super(props);this.state={needComp: false}}componentDidMount(){setTimeout(()=>{this.setState({needComp: true})},5*1000)}handleClick=()=>{this.setState({needComp: true});}render(){return(<><buttononClick={()=>{console.log(this.state.needComp)}}>log</button><buttononClick={this.handleClick}>load comp</button>{this.state.needComp ? <Comp/> : "loding"}</>);}}// the page should render two Comps after 5 seconds, but only one shows// another Comp doesn't show until you click another App's 'load comp' buttonrender(<><App/><App/></>,document.getElementById('root'));
The text was updated successfully, but these errors were encountered:
comp.js
index.js
The text was updated successfully, but these errors were encountered: