Skip to content

Instantly share code, notes, and snippets.

@SahanAmarsha
Created March 15, 2022 17:02
Show Gist options
  • Save SahanAmarsha/46d4fab9e7d8ee48b1bbdf40637f3d4a to your computer and use it in GitHub Desktop.
Save SahanAmarsha/46d4fab9e7d8ee48b1bbdf40637f3d4a to your computer and use it in GitHub Desktop.
Define routes in our React App
// 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