Skip to content

Instantly share code, notes, and snippets.

@MicroBenz
Created July 6, 2018 08:34
Show Gist options
  • Save MicroBenz/784981a6d73b84ed0cfdf08d9d264cbe to your computer and use it in GitHub Desktop.
Save MicroBenz/784981a6d73b84ed0cfdf08d9d264cbe to your computer and use it in GitHub Desktop.
React Code Splitting
import { Switch, Route } from 'react-router-dom';
import Loadable from 'react-loadable';
const Login = Loadable({
loader: () => import('./pages/Login'),
loading: () => null
});
const Dashboard = Loadable({
loader: () => import('./pages/Dashboard'),
loading: () => null
});
const User = Loadable({
loader: () => import('./pages/User'),
loading: () => null
});
const Routes = () => {
return (
<Switch>
<Route path="/login" exact component={Login} />
<Route path="/dashboard" exact component={Dashboard} />
<Route path="/users" exact component={User} />
</Switch>
);
};
export default Routes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment