react-chrome-extension-router icon indicating copy to clipboard operation
react-chrome-extension-router copied to clipboard

Private Route

Open NathanBrodin opened this issue 2 years ago • 0 comments

Hi, I am trying to build a private route which allows to go to a certain component only if the user is logged-in.

With 'react-router-dom', it is supposed to look like this:

export default function PrivateRoute({ children }) { const { currentUser } = useAuth()

return currentUser ? children : <Navigate to="/login" /> }

And I'm calling this with: <Router> <Route exact path="/" element={<PrivateRoute> <Dashboard /> </PrivateRoute> } /> <Router />

Any idea on how to implement it with this package ? Thank you for your help!

NathanBrodin avatar Sep 06 '22 15:09 NathanBrodin