Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Last active November 8, 2018 07:56
Show Gist options
  • Save gladchinda/6d72d00e2cb493be005a0db2001352dd to your computer and use it in GitHub Desktop.
Save gladchinda/6d72d00e2cb493be005a0db2001352dd to your computer and use it in GitHub Desktop.
import React, { Suspense } from 'react';
import { Router } from '@reach/router';
import Loading from './Loading';
const Home = React.lazy(() => import('./Home'));
const Dashboard = React.lazy(() => import('./Dashboard'));
const Overview = React.lazy(() => import('./Overview'));
const History = React.lazy(() => import('./History'));
const NotFound = React.lazy(() => import('./NotFound'));
function App() {
return (
<div>
<Suspense fallback={<Loading />}>
<Router>
<Home path="/" />
<Dashboard path="dashboard">
<Overview path="/" />
<History path="/history" />
</Dashboard>
<NotFound default />
</Router>
</Suspense>
</div>
)
}
@tarjei
Copy link

tarjei commented Nov 8, 2018

Thanks for the article!
You should add the content of one of the Route components(f.x. Dashboard) to this example to show what is happening within that component :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment