So I'm trying to create role-based routes, however I can't figure it out how to display specific pages that relies on which role user has. Example:
<Route exact path="/users">
{(localStorage.getItem("role") === "ROLE_ADMIN" && (
<Appbar/>) && (
<Users/>))}
</Route>
So let's say when user with ROLE_ADMIN directs to /users path, it should display and components. But I want to direct him to the other component if he doesn't have that role. Can anyone help me? Thanks!