Created
August 29, 2019 07:49
-
-
Save nightspirit/b6d78267855018e09f84e96e608b9221 to your computer and use it in GitHub Desktop.
react-loadable + react-router
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 React from 'react' | |
import { Switch, Route } from 'react-router-dom' | |
import Loadable from 'react-loadable' | |
const Loading = () => <div>loading...</div> | |
const Home = Loadable({ | |
loader: () => import('./Home'), | |
loading: Loading | |
}) | |
const Product = Loadable({ | |
loader: () => import('./Product'), | |
loading: Loading | |
}) | |
const About = Loadable({ | |
loader: () => import('./About'), | |
loading: Loading | |
}) | |
const App = () => ( | |
<Switch> | |
<Route exact path="/" component={Home}/> | |
<Route path="/product" component={Product}/> | |
<Route path="/about" component={About}/> | |
<Route component={NoMatch}/> | |
</Switch> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment