Skip to content

Instantly share code, notes, and snippets.

@charisTheo
Created August 21, 2021 19:14
Show Gist options
  • Select an option

  • Save charisTheo/8978feead100432402a02f0e0f371a54 to your computer and use it in GitHub Desktop.

Select an option

Save charisTheo/8978feead100432402a02f0e0f371a54 to your computer and use it in GitHub Desktop.
import React from 'react'
import {
BrowserRouter as Router,
Switch
} from 'react-router-dom'
const HomePage = React.lazy(() => import('./Pages/Home'))
const LoginPage = React.lazy(() => import('./Pages/Login'))
export default function () {
return (
<Router>
<Switch>
<Route exact path='/'>
<React.Suspense fallback={<p>Loading...</p>}>
<HomePage />
</React.Suspense>
</Route>
<Route exact path='/login'>
<React.Suspense fallback={<p>Loading...</p>}>
<LoginPage />
</React.Suspense>
</Route>
</Switch>
</Router>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment