Created
July 12, 2020 21:31
-
-
Save crypticminds/4be0cbe215b20ad391977cd09e6c1c19 to your computer and use it in GitHub Desktop.
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 React , {lazy , Suspense} from "react"; | |
import { Route, Switch } from "react-router-dom"; | |
const Home = lazy(() => | |
import("./home" /* webpackChunkName: "HomePage" */) | |
); | |
const Login = lazy(() => | |
import("./login" /* webpackChunkName: "LoginPage" */) | |
); | |
const Profile = lazy(() => | |
import("./profile" /* webpackChunkName: "Profile" */) | |
); | |
const MyComponent = () => { | |
return ( | |
<Suspense fallback={<div>Loading.....</div>}> | |
<Switch> | |
<Route path="/home"> | |
<Home /> | |
</Route> | |
<Route path="/login"> | |
<Login /> | |
</Route> | |
<Route path="/profile"> | |
<Profile /> | |
</Route> | |
</Switch> | |
</Suspense> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment