As my routes the Sidebar
and the topbar is rendering with Signup
and login page.
I want to render the Signup
and login page with a seperate route where the sidebar should not render. And the sidebar and the Topbar
should render only with the home and other component.
I've used react-router-dom
for routes and material ui components for the theme.
This is the code:
import { Route, Routes } from "react-router-dom";
import { useState } from "react";
import Home from "./pages/Home";
import Page1 from "./pages/page1";
import LogIn from './pages/LogIn'
import SignUp from './pages/SignUp'
import Sidebar from "./scenes/global/Sidebar"
import Topbar from "./scenes/global/Topbar"
import { CssBaseline, ThemeProvider } from "@mui/material";
import { ColorModeContext, useMode } from "./theme";
function App() {
const [theme, colorMode] = useMode();
const [isSidebar, setIsSidebar] = useState(true);
return (
<ColorModeContext.Provider value={colorMode}>
<ThemeProvider theme={theme}>
<CssBaseline />
<div className="app">
<Routes>
<Route path="/" element={<SignUp/>}/>
<Route path="/login" element={<LogIn/>}/>
</Routes>
<Sidebar isSidebar={isSidebar}/>
<main className="content">
<Topbar setIsSidebar={setIsSidebar}/>
<Routes>
<Route path="/home" element={<Home/>}/>
<Route path="/page1" element={<Page1/>}/>
</Routes>
</main>
</div>
</ThemeProvider>
</ColorModeContext.Provider>
)
}
export default App