Skip to content

Instantly share code, notes, and snippets.

@crypticminds
Created July 12, 2020 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crypticminds/4be0cbe215b20ad391977cd09e6c1c19 to your computer and use it in GitHub Desktop.
Save crypticminds/4be0cbe215b20ad391977cd09e6c1c19 to your computer and use it in GitHub Desktop.
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