Last active
November 22, 2021 18:19
react router v6 private route usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function App() { | |
return ( | |
<div className="App"> | |
<Header /> | |
<Routes> | |
<Route path="/" element={<Login />} /> | |
<Route path="*" element={<NotFound />} /> | |
<Route | |
path="dashboard" | |
element={<PrivateRoute roles={[ROLE.ADMIN]} component={Dashboard} />} | |
/> | |
<Route | |
path="users" | |
element={<PrivateRoute roles={[ROLE.ADMIN, ROLE.USER]} component={Users} />} | |
/> | |
</Routes> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment