Skip to content

Instantly share code, notes, and snippets.

@davidgilbertson
Created September 9, 2018 05:04
Show Gist options
  • Save davidgilbertson/c9e07c72f652fc63632f3a42531c02ee to your computer and use it in GitHub Desktop.
Save davidgilbertson/c9e07c72f652fc63632f3a42531c02ee to your computer and use it in GitHub Desktop.
import React from 'react';
class AdminPageLoader extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
AdminPage: null,
}
}
componentDidMount() {
import('./AdminPage').then(module => {
this.setState({ AdminPage: module.default });
});
}
render() {
const { AdminPage } = this.state;
return AdminPage
? <AdminPage {...this.props} />
: <div>Loading...</div>;
}
}
export default AdminPageLoader;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment