Created
January 6, 2021 06:30
-
-
Save velotiotech/77e41e9378c4669398ae1e385849d2e0 to your computer and use it in GitHub Desktop.
Eliminate render-blocking resources - using webpack's magic comments
This file contains 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 { Suspense, lazy } from 'react'; | |
import { Redirect, Route, Switch } from 'react-router-dom'; | |
import Loader from '../../components/Loader'; | |
import './style.scss'; | |
const Login = lazy(() => | |
import( | |
/* webpackChunkName: "login" */ /* webpackPreload: true */ '../../containers/Login' | |
) | |
); | |
const Signup = lazy(() => | |
import( | |
/* webpackChunkName: "signup" */ /* webpackPrefetch: true */ '../../containers/Signup' | |
) | |
); | |
const AuthLayout = () => { | |
return ( | |
<Suspense fallback={<Loader />}> | |
<Switch> | |
<Route path="/auth/login" component={Login} /> | |
<Route path="/auth/signup" component={Signup} /> | |
<Redirect from="/auth" to="/auth/login" /> | |
</Switch> | |
</Suspense> | |
); | |
}; | |
export default AuthLayout; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment