React Router v6 tutorial in Hindi #11 Protected Route
Вставка
- Опубліковано 16 вер 2024
- In this react-router 6 tutorial in Hindi, we learn how to navigate on button click or Navigate programmatically. This video is made by anil Sidhu in Hindi
steps of video
Make Login Page
Make Protected Route
Use Protected Route
Use Local Storage to complete the flow
Insta: code.steps
Complete playlist for react router
• React router v6 tutori...
React js Latest Playlist in Hindi: • React tutorial for beg...
inst id: @code.steps
Best protected routing ever! thanks for the video 👏
thankss❤ iam not coding student pro but job ke liye apki sari vedios dekta hu apki sari vedios gager me sager vali hoti h short time me kitna kuch sikha dete ho app such me sir super seuper all vedios best of luck ase hee agee vedios amazing bnane ke liye❤❤❤
धन्यवाद अनिल भाई। It hepled me in a critical time.
Thanks bhai
i was stuck on this part from last one week but your video saved me
Thank you so much and All the best !!
Thank for the video very nicely explain as always you did... Short and great
Here's the onclick function to implement the logout functionality =>
function logout() {
localStorage.removeItem("Login");
navigate("/login");
}
9:20 Love that sound um um um😄
Really need this this video at this time... thanks bro 😊
Thanks for this video I was stuck at this for so long time...
Nice i was about to search for this, how we set sessions on our pages!👍
Easy and wonderful video Sir ji...
Many thanks for this quick help on auth routing.
Awesome
Sir please login or signup page system functional component ke through video bna dijiye please
Thank You Brother!
We all love you ❤🫶
using Navigate Cmpoenent is best to use here because in your logic whather the user actuall log in or not they will be able to see desired route page for some mile second then the condition is run in the useeffect so gradually usere to able to needed routes without login so its better to use Navigate Componenet we should use usenavigate on button click something like that
It works but when you click protected route multiple times in this example i.e home. you see a glimse/flash of the protected route content. How to fix that?
Upload more video on regular basis 🙏
BT- 00:00:13 kuch-uch-uch-uch
thank you sir
Thank You so much 😅, finally I got it 😢
Glad I could help!
Bhai ye method me agar koi inspect me jakar state change kr de to??
thanks gurudev
hey thanks for this video, could you please provide the code on git, my home page and login page content are not showing after trying this.
Best explanation 🤞
just amazing🔥🔥
hi when I call useEffect, I get invalid hook call exception
improved apporach i guess more correct by setting the dependecy array that cause rerenders to affect useEffect hook to initiate
import React, { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
function Login() {
const navigate = useNavigate();
const [isLoggedIn, setIsLoggedIn] = useState(false);
const login = () => {
localStorage.setItem('login', true);
setIsLoggedIn(true);
};
useEffect(() => {
let login = localStorage.getItem('login');
if (login) {
navigate('/');
}
}, [isLoggedIn]);
return (
Login
);
}
Please correct me if i'm wrong or its not any issue
What if user change the value of 'login' to true from localstorage? In that case also, user can see all the screens without login.
This is just an example in real world apps a token is used to check user auth
can you show example how can user change coz i don't see any way user can do this...
Sir if there are 50+ pages on website, it's much overwhelming to add protected to 50 Routes, is not there, any other solution?
is that protected.js component is a HOC ?
I have project on reactjs and nodejs .
Database is postgresql how to deploy on Tomcat Apache server
Sir Login is happening but contents are not visible on navigation
Same issue could you help me
Write :-
{Protected Component ={ "Home" }}
useEffect me dependency array kyo pass nhi kiya ??
thank you
nice bro jai hind
please can you register your videos in english because we really need it
soon :)
Hindi mai thik hai😂❤
Learn Hindi first
Bro ERROR thy raha h:
Error: A is only ever to be used as the child of element, never rendered directly. Please wrap your in a
routes tag ke andar route likhte hai
thanks
But what if we don't want to show Navbar on Login?
Bhaiya components useffect se pahele hi render nhi ho jayga
I have tries the same code but its not working
This is not working. Getting error "Operation is unsecure".
Error is solved. It occurs in Edge only
But not working for me can anyone help
Thanks bro for saving my ass
Is it safe?
WELL DONE 🟢
How access code
No protected route in English
ye work hi nhi ho raha sir
YES BRO I THINK IN NEW REACT IT CHANGED
insta id ka link bhi add kiya karo description me