Last active
September 18, 2018 02:55
-
-
Save isacjunior/554d637ab337337321a3e23fd33c51a3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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