Skip to content

Instantly share code, notes, and snippets.

@velotiotech
Created January 6, 2021 06:30
Show Gist options
  • Save velotiotech/77e41e9378c4669398ae1e385849d2e0 to your computer and use it in GitHub Desktop.
Save velotiotech/77e41e9378c4669398ae1e385849d2e0 to your computer and use it in GitHub Desktop.
Eliminate render-blocking resources - using webpack's magic comments
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