-
-
Save Nilanth/2e7a15fea2b3b89e964177e6fdcd4708 to your computer and use it in GitHub Desktop.
ProtectedRoutes
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 } from 'react'; | |
import { Route, Switch } from 'react-router-dom'; | |
import routes from 'routes'; // Route list | |
import Loader from 'sharedComponent/Loader'; | |
const ProtectedRoutes = () => ( | |
<Switch> | |
<Suspense | |
fallback={<Loader />} | |
> | |
{routes.map(({ component: Component, path, exact }) => ( | |
<Route | |
path={`/${path}`} | |
key={path} | |
exact={exact} | |
> | |
<Component /> | |
</Route> | |
))} | |
</Suspense> | |
</Switch> | |
); | |
export default ProtectedRoutes; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment