Sometime we have a list of routes for specific user roles, such as admin, user, editor, etc. In this case, we want to show the role based routes permission then we can use RoleBasedGuard component from app.
RoleBasedGuard.jsx
_15
import useAuth from "hooks/useAuth";
_15
_15
const RoleBasedGuard = ({ children, roles }) => {
_15
const { user } = useAuth();
_15
_15
const loggedInUserRole = user?.role;
_15
_15
if (loggedInUserRole && roles.includes(loggedInUserRole)) {