react-universal-component
react-universal-component copied to clipboard
How to check that the component has loaded?
What is the best way to detect that the DoThis has loaded?
const DoThis = universal(import(/* webpackChunkName: 'do-this' */ 'src/do-this.js'));
class DoThisLoader extends React.Component {
constructor() {
super();
this.state = {
dataLoaded: false,
};
}
componentWillMount() {
DoThis.preload();
}
componentDidMount() {
loadSomeData().then(() => this.setState({ dataLoaded: true }));
}
render() {
return dataLoaded && DoThis ? <DoThis /> : <DoThat />;
}
}