Skip to content

Instantly share code, notes, and snippets.

@isacjunior
Last active September 18, 2018 02:55
Show Gist options
  • Save isacjunior/554d637ab337337321a3e23fd33c51a3 to your computer and use it in GitHub Desktop.
Save isacjunior/554d637ab337337321a3e23fd33c51a3 to your computer and use it in GitHub Desktop.
import React from 'react'
import BrowserRouter from 'react-router-dom/BrowserRouter'
import Route from 'react-router-dom/Route'
import Switch from 'react-router-dom/Switch'
import LazyImport from './Components/LazyImport'
// Precisamos informar ao webpack qual o nome que ele dará a cada chunk, por isso esta notação.
const Nav = LazyImport({
loader: () => import('./Components/Nav'/* webpackChunkName: 'nav' */),
})
const Main = LazyImport({
loader: () => import('./Components/Main'/* webpackChunkName: 'main' */),
})
const Other = LazyImport({
loader: () => import('./Components/Other'/* webpackChunkName: 'other' */),
})
const Routes = () => (
<BrowserRouter>
<>
<Nav />
<Switch>
<Route exact path="/" component={Main} />
<Route path="/other" component={Other} />
</Switch>
</>
</BrowserRouter>
)
export default Routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment