I have an admin dashboard and I Implemented it nested Route successfully But its does not render the page. when I click it shows this
It change the URL but not render the page
How i fix this, if anyone know please tell me
App.js
<Router>
<Navbar />
<Routes>
<Route exact path="/" element={<Home />} />
<Route exact path="/service" element={<Service />} />
<Route exact path="/contact" element={<Contact />} />
<Route exact path="/login" element={<Login />} />
<Route exact path="/reset" element={<Reset />} />
<Route exact path="/reset/:token" element={<Newpassword />} />
{/* Redirect to their dashboard */}
<Route exact path="/employee" element={<Employee />} />
<Route exact path="/publisher" element={<Publisher />} />
{/* admin pages */}
<Route path="/admin" element={<Admin />}>
<Route path="/admin/project" element={<Project />} />
<Route path="/admin/user" element={<User />} />
</Route>
</Routes>
</Router>
Admin.js
import React from 'react'
import { CDBSidebar, CDBSidebarContent, CDBSidebarHeader, CDBSidebarFooter, CDBSidebarMenu, CDBSidebarMenuItem } from "cdbreact"
import { NavLink, Outlet } from 'react-router-dom';
import "./AllStyle.css"
const Admin = () => {
return (
<div>
<div style={{ display: 'flex', height: '100vh', overflow: 'scroll initial' }}>
<CDBSidebar textColer="#fff" backgroundColor="rgb(0,7,61)">
<CDBSidebarHeader prefix={<i className="fa fa-bars fa-large"></i>}>
<h4>Admin</h4>
</CDBSidebarHeader>
<CDBSidebarContent className="sidebar-content">
<CDBSidebarMenu>
<NavLink to="/admin/user">
<CDBSidebarMenuItem icon="portrait">
ALL USER
</CDBSidebarMenuItem>
<hr></hr>
</NavLink>
<NavLink to="/admin/project">
<CDBSidebarMenuItem icon="file-contract">
Add Project
</CDBSidebarMenuItem>
<hr></hr>
</NavLink>
<NavLink to="/login">
<CDBSidebarMenuItem icon="sign-out-alt">
Logout
</CDBSidebarMenuItem>
<hr></hr>
</NavLink>
</CDBSidebarMenu>
</CDBSidebarContent>
<hr></hr>
<CDBSidebarFooter style={{ textAlign: 'center' }}>
<div className="sidebar-btn-wrapper" style={{ padding: '20px 5px' }}>
Evalue Content portal
</div>
</CDBSidebarFooter>
</CDBSidebar>
</div>
<Outlet /> //using Outlet to render the child component
</div>
)
}
export default Admin
i want to implement that, if click the user then render the user component inside the admin dashboard
Update:
after implement <Outlet/>
, URL changed but did not showing content for child component But I see the error in the console.
Warning: Failed prop type: ForwardRef: prop type `toggled` is invalid; it must be a function, usually from the `prop-types` package, but received `undefined`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.
if anyone know please tell me how to fix this Typo error
Update 2:
after using <Outlet
> it worked but one catch was the child content shown below the admin menu
can you please tell me how to fix this