Skip to content

Instantly share code, notes, and snippets.

View Donmclean's full-sized avatar
🎧
Building a fleet of the world's first AI DJs 👨‍💻

Don Mclean Donmclean

🎧
Building a fleet of the world's first AI DJs 👨‍💻
View GitHub Profile
@Donmclean
Donmclean / app.js
Created June 9, 2017 22:54 — forked from acdlite/app.js
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {