degmods.com/src/App.tsx

41 lines
923 B
TypeScript
Raw Normal View History

2024-07-11 11:45:59 +00:00
import { Route, Routes } from 'react-router-dom'
2024-07-10 18:31:54 +00:00
import { Layout } from './layout'
2024-07-11 11:45:59 +00:00
import { routes } from './routes'
import { useEffect } from 'react'
import './styles/styles.css'
2024-07-10 18:31:54 +00:00
function App() {
useEffect(() => {
// Find the element with id 'root'
const rootElement = document.getElementById('root')
if (rootElement) {
// Add the class to the element
rootElement.classList.add('bodyMain')
}
// Cleanup function (optional): Remove the class when the component unmounts
return () => {
if (rootElement) {
rootElement.classList.remove('bodyMain')
}
}
}, [])
2024-07-11 11:45:59 +00:00
return (
<Routes>
<Route element={<Layout />}>
{routes.map((route, index) => (
<Route
key={route.path + index}
path={route.path}
element={route.element}
/>
))}
</Route>
</Routes>
)
}
export default App