Could you please share multiple private route example. What your suggestion to keep the code looks clean? Thank you.
Hey Hasan!
You can put them as adjacent routes
function App() { return ( <BrowserRouter> <Routes> <Route path="/private-2" element={ <PrivateRoute> <Private1 /> </PrivateRoute> } /> <Route path="/private-2" element={ <PrivateRoute> <Private2 /> </PrivateRoute> } /> </Routes> </BrowserRouter> ); }
or you can put all private routes in a single parent component that is private
function App() { return ( <BrowserRouter> <Routes> <Route path="/all-private" element={ <PrivateRoute> <AllPrivate /> </PrivateRoute> } /> </Routes> </BrowserRouter> ); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Could you please share multiple private route example. What your suggestion to keep the code looks clean?
Thank you.
Hey Hasan!
You can put them as adjacent routes
or you can put all private routes in a single parent component that is private