have this import { Routes, Route, BrowserRouter } from "react-router-dom"; import…
Jump to turn (7)
- 1have this import { Routes, Route, BrowserRouter } from "react-router-dom"; impor
- 2with this it work normally
- 3but it work not normally by this }> } /> } /> ? Why
- 4Great, now the children is undefined
- 5yeah!! i already console.log it to know the value is undefined? why u do that to
- 6it work perfectly with this } /> } /> . but i want to props thgrouh the children
- 7are you missunderstand? }> {/ nest the child routes within the MainLayout compon
- User
have this import { Routes, Route, BrowserRouter } from "react-router-dom"; import MainLayout from "../Layout/mainLayout/MainLayout"; import RoomMain from "../Rooms/pages"; import RoomDetail from "../Rooms/pages/Detail"; export default function Router() { return ( <Route path='/' element={}> <Route path='/room' element={} /> <Route path='/room/:roomId' element={} /> ); } and this import Sider from '../components/Sider'; import Navbar from '../components/Navbar'; import '../../CSS/index.css'; import { ReactNode } from 'react';
interface MainLayoutProps { children?: ReactNode; } export default function MainLayout({ children }: MainLayoutProps) { console.log(children) return ( {children!} ); }
but the children props always undefined
- Assistant