Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react router dom v6

import {BrowserRouter,Routes,Route,Navigate,Outlet} from "react-router-dom";
<BrowserRouter>
    <Routes>
        <Route path="/" element={<Navigate to="/main" />} />
        <Route path="/home/*" element={<div><Outlet/></div>}>
            <Route path="page1" element={<h1>home page 1</h1>} />
            <Route path="page2" element={<h1>home page 2</h1>} />
        </Route>
        <Route path="/notification" element={<h1>notification page</h1>} />
        <Route path="/notification/:id" element={<h1>notification details pages</h1>} />
        <Route path="/login" element={<h1> login page </h1>} />
    </Routes>
</BrowserRouter>
 
PREVIOUS NEXT
Tagged: #react #router #dom
ADD COMMENT
Topic
Name
6+7 =