Created
March 15, 2022 17:02
-
-
Save SahanAmarsha/46d4fab9e7d8ee48b1bbdf40637f3d4a to your computer and use it in GitHub Desktop.
Define routes in our React App
This file contains hidden or 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
// src/routes.ts | |
// pages | |
import Home from "./pages/Home"; | |
import About from "./pages/About"; | |
import Products from "./pages/Products"; | |
// other | |
import {FC} from "react"; | |
// interface | |
interface Route { | |
key: string, | |
title: string, | |
path: string, | |
enabled: boolean, | |
component: FC<{}> | |
} | |
export const routes: Array<Route> = [ | |
{ | |
key: 'home-route', | |
title: 'Home', | |
path: '/', | |
enabled: true, | |
component: Home | |
}, | |
{ | |
key: 'about-route', | |
title: 'About', | |
path: '/about', | |
enabled: true, | |
component: About | |
}, | |
{ | |
key: 'products-route', | |
title: 'Products', | |
path: '/products', | |
enabled: true, | |
component: Products | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment