Created
July 6, 2018 08:20
-
-
Save MicroBenz/c9797a3c3dd5e2aaf3a6cf773c02abdb to your computer and use it in GitHub Desktop.
React Code Splitting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyComponent extends React.Component { | |
state = { | |
Bar: null | |
}; | |
componentWillMount() { | |
import('./components/Bar').then(Bar => { | |
this.setState({ Bar }); | |
}); | |
} | |
render() { | |
let {Bar} = this.state; | |
if (!Bar) { | |
return <div>Loading...</div>; | |
} else { | |
return <Bar/>; | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment