Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
react-loadable + react-router
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