Created
March 11, 2018 11:34
-
-
Save mohandere/2af998f8b9faa3957e136ff6c538f53a to your computer and use it in GitHub Desktop.
asyncRoutes in CRA
This file contains hidden or 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 React from 'react'; | |
import { | |
Route, | |
Switch | |
} from 'react-router'; | |
import Loadable from 'react-loadable'; | |
import AppLoader from './common/components/AppLoader'; | |
// Import modules/routes | |
import About from './about'; | |
import PageNotFound from './common/components/PageNotFound'; | |
// Code splitting with dynamic import | |
// https://reactjs.org/docs/code-splitting.html | |
const Home = Loadable({ | |
loader: () => | |
import ('./home'), | |
loading: AppLoader | |
}); | |
export default ( | |
<Switch> | |
<Route exact path="/" component={Home} /> | |
<Route path="/about" component={About} /> | |
<Route path="*" component={PageNotFound} /> | |
</Switch> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment