
Protected Routes in React using React Router
video description
Date: 2022-03-14
Related videos
Comments and reviews: 7
Akash
I tried solving a use case using this approach but could not solve it. Have 2-3 open routes, 2-3 protected-routes, and a wild card route at the end of router switch. The protectedRoute being a component renders everything and starts executing whatever logic is inside it. For example, I hit a wild card route /asd and I want to redirect all wild card route to /home. Since protectedRoute component comes before the wild card route in App.js/.tsx the wild card route is never hit and I am redirected to the else condition logic inside my protectedRoute.
reply
I tried solving a use case using this approach but could not solve it. Have 2-3 open routes, 2-3 protected-routes, and a wild card route at the end of router switch. The protectedRoute being a component renders everything and starts executing whatever logic is inside it. For example, I hit a wild card route /asd and I want to redirect all wild card route to /home. Since protectedRoute component comes before the wild card route in App.js/.tsx the wild card route is never hit and I am redirected to the else condition logic inside my protectedRoute.
reply
Vignesh
Hey, Hello all, I need help, so someone please do help me out as soon as possible. I followed this tutorial to implement protected routing in react, but unfortunately, whenever I refresh the page, I'm going back to the login page. Please somebody help me.
reply
Hey, Hello all, I need help, so someone please do help me out as soon as possible. I followed this tutorial to implement protected routing in react, but unfortunately, whenever I refresh the page, I'm going back to the login page. Please somebody help me.
reply
chan
when i was refresh /app profile, thats redirect to homepage. Why? i dont want to redirect from /app to homepage, i want stay in /app after logged in. How can i do it ?
reply
when i was refresh /app profile, thats redirect to homepage. Why? i dont want to redirect from /app to homepage, i want stay in /app after logged in. How can i do it ?
reply
Rojan
I am wondering, what will happen if you pass random url name, when you are still logged in. In my code, I couldnot show 404 page not found in such condition.
reply
I am wondering, what will happen if you pass random url name, when you are still logged in. In my code, I couldnot show 404 page not found in such condition.
reply
Ante
What if the routes I want to protect use the render prop because they render components that have props themselves? I get errors using this method.
reply
What if the routes I want to protect use the render prop because they render components that have props themselves? I get errors using this method.
reply
The
I looked up how to hide the Navbar/Header from certain pages ... this didn't help with that but it did clear up other issues I was having....lol
reply
I looked up how to hide the Navbar/Header from certain pages ... this didn't help with that but it did clear up other issues I was having....lol
reply
yumi
at first 4 secs. of listening to his voice thought it was a text to voice and suddenly after hearing an unexpected words, ... what!!???
reply
at first 4 secs. of listening to his voice thought it was a text to voice and suddenly after hearing an unexpected words, ... what!!???
reply
Add a review, comment
Other channel videos















