Created
July 6, 2018 08:34
-
-
Save MicroBenz/784981a6d73b84ed0cfdf08d9d264cbe 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
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