Last active
March 17, 2022 09:59
-
-
Save SahanAmarsha/44b1164d7f999c276663634c6b984430 to your computer and use it in GitHub Desktop.
App.tsx Iterating Through Routes
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/App.tsx | |
import React from "react"; | |
import { Box, CssBaseline, ThemeProvider } from "@mui/material"; | |
import { createTheme } from "@mui/material/styles"; | |
import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; | |
import { routes as appRoutes } from "./routes"; | |
function App() { | |
// define theme | |
const theme = createTheme({ | |
palette: { | |
primary: { | |
light: "#63b8ff", | |
main: "#0989e3", | |
dark: "#005db0", | |
contrastText: "#000", | |
}, | |
secondary: { | |
main: "#4db6ac", | |
light: "#82e9de", | |
dark: "#00867d", | |
contrastText: "#000", | |
}, | |
}, | |
}); | |
return ( | |
<ThemeProvider theme={theme}> | |
<CssBaseline /> | |
<Box height="100vh" display="flex" flexDirection="column"> | |
<Router> | |
<Routes> | |
{appRoutes.map((route) => ( | |
<Route | |
key={route.key} | |
path={route.path} | |
element={<route.component />} | |
/> | |
))} | |
</Routes> | |
</Router> | |
</Box> | |
</ThemeProvider> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment