Skip to content

Instantly share code, notes, and snippets.

@mcallegari10
Created July 9, 2018 18:33
Show Gist options
  • Save mcallegari10/407ca20c59f7b358a5af711df8cf5fc7 to your computer and use it in GitHub Desktop.
Save mcallegari10/407ca20c59f7b358a5af711df8cf5fc7 to your computer and use it in GitHub Desktop.
import React from 'react';
// We can use react-loadable to cover the most possibles outcomes of the code splitting
import Loadable from 'react-loadable';
// My Loader component
import Loader from '@components/Loader';
// Create the async route
const AsyncRoute = Loadable({
loader: () => import('./index'),
loading() {
return <Loader />;
}
});
// This is the component the React Router will use
const MyRoute = props => <AsyncRoute {...props} />;
export default MyRoute;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment