mirror of
https://github.com/gregberge/loadable-components.git
synced 2026-01-25 15:24:15 +00:00
26 lines
793 B
JavaScript
26 lines
793 B
JavaScript
import React from 'react'
|
|
import { Router, Link } from '@reach/router'
|
|
import loadable from '@loadable/component'
|
|
import './App.css'
|
|
|
|
const NotFound = loadable(() => import('./NotFound'))
|
|
const Home = loadable(() => import('./Home'))
|
|
const About = loadable(() => import('./About'))
|
|
const Contact = loadable(() => import('./Contact'))
|
|
|
|
const App = () => (
|
|
<React.Fragment>
|
|
<Link to="/">Home</Link>
|
|
<Link to="/about">About</Link>
|
|
<Link to="/contact">Contact</Link>
|
|
<Router>
|
|
<NotFound default fallback={<div>loading...</div>} />
|
|
<Home path="/" fallback={<div>loading...</div>} />
|
|
<About path="/about" fallback={<div>loading...</div>} />
|
|
<Contact path="/contact" fallback={<div>loading...</div>} />
|
|
</Router>
|
|
</React.Fragment>
|
|
)
|
|
|
|
export default App
|