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

КОМЕНТАРІ • 64

  • @sandiproy9361
    @sandiproy9361 Рік тому +9

    Best protected routing ever! thanks for the video 👏

  • @knoladgetv....5408
    @knoladgetv....5408 10 місяців тому +1

    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❤❤❤

  • @sidharthvyas5883
    @sidharthvyas5883 Рік тому +1

    धन्यवाद अनिल भाई। It hepled me in a critical time.

  • @kushmunot8651
    @kushmunot8651 2 роки тому +1

    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 !!

  • @contactpbs2058
    @contactpbs2058 2 роки тому +3

    Thank for the video very nicely explain as always you did... Short and great

  • @amardeepsinghchauhan5994
    @amardeepsinghchauhan5994 Рік тому +8

    Here's the onclick function to implement the logout functionality =>
    function logout() {
    localStorage.removeItem("Login");
    navigate("/login");
    }

  • @FaisalAnsari-ch4pl
    @FaisalAnsari-ch4pl Рік тому +3

    9:20 Love that sound um um um😄

  • @syedusama7773
    @syedusama7773 2 роки тому +1

    Really need this this video at this time... thanks bro 😊

  • @KSHMRGAMING
    @KSHMRGAMING 2 роки тому +1

    Thanks for this video I was stuck at this for so long time...

  • @nikhilkumarjamwal5322
    @nikhilkumarjamwal5322 Місяць тому +1

    Nice i was about to search for this, how we set sessions on our pages!👍

  • @swapnilcodes
    @swapnilcodes 2 роки тому +1

    Easy and wonderful video Sir ji...

  • @ajayshukla7238
    @ajayshukla7238 6 місяців тому

    Many thanks for this quick help on auth routing.

  • @NIKITPULEKAR
    @NIKITPULEKAR Місяць тому

    Awesome

  • @bhavamsingh8092
    @bhavamsingh8092 2 місяці тому

    Sir please login or signup page system functional component ke through video bna dijiye please

  • @whysumancode
    @whysumancode Рік тому

    Thank You Brother!
    We all love you ❤🫶

  • @khanapeena2191
    @khanapeena2191 5 місяців тому

    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

  • @maxvhanamane840
    @maxvhanamane840 2 роки тому +6

    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?

  • @vishalpawarrr
    @vishalpawarrr 2 роки тому +1

    Upload more video on regular basis 🙏

  • @ayushpal790
    @ayushpal790 5 місяців тому +3

    BT- 00:00:13 kuch-uch-uch-uch

  • @baolong9679
    @baolong9679 Рік тому +1

    thank you sir

  • @ayanonlinee
    @ayanonlinee Рік тому

    Thank You so much 😅, finally I got it 😢

  • @edwardgaming5681
    @edwardgaming5681 5 місяців тому

    Bhai ye method me agar koi inspect me jakar state change kr de to??

  • @shivcoder3610
    @shivcoder3610 Рік тому +1

    thanks gurudev

  • @ravindrap884
    @ravindrap884 Рік тому +1

    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.

  • @CodtachiYoutube
    @CodtachiYoutube Рік тому

    Best explanation 🤞

  • @khizarijaz6712
    @khizarijaz6712 Рік тому

    just amazing🔥🔥

  • @KaushikR-qq7pf
    @KaushikR-qq7pf Рік тому +2

    hi when I call useEffect, I get invalid hook call exception

  • @sahilgoyal9422
    @sahilgoyal9422 3 місяці тому

    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

    );
    }

    • @sahilgoyal9422
      @sahilgoyal9422 3 місяці тому

      Please correct me if i'm wrong or its not any issue

  • @CodeWithAnurag
    @CodeWithAnurag 11 місяців тому +1

    What if user change the value of 'login' to true from localstorage? In that case also, user can see all the screens without login.

    • @alwazkazi1916
      @alwazkazi1916 9 місяців тому

      This is just an example in real world apps a token is used to check user auth

    • @saim4556
      @saim4556 5 місяців тому

      can you show example how can user change coz i don't see any way user can do this...

  • @HassanJawedWani
    @HassanJawedWani 3 місяці тому

    Sir if there are 50+ pages on website, it's much overwhelming to add protected to 50 Routes, is not there, any other solution?

  • @prashantpriyadarshi5810
    @prashantpriyadarshi5810 2 роки тому +1

    is that protected.js component is a HOC ?

  • @GIS-Engineer
    @GIS-Engineer 10 місяців тому

    I have project on reactjs and nodejs .
    Database is postgresql how to deploy on Tomcat Apache server

  • @madhusudankrishnamoorthy3793
    @madhusudankrishnamoorthy3793 2 роки тому +6

    Sir Login is happening but contents are not visible on navigation

    • @T_anishka
      @T_anishka Рік тому

      Same issue could you help me

    • @aashikroy2198
      @aashikroy2198 Рік тому

      Write :-
      {Protected Component ={ "Home" }}

  • @programmingmaze4493
    @programmingmaze4493 4 місяці тому

    useEffect me dependency array kyo pass nhi kiya ??

  • @vrajthakar5749
    @vrajthakar5749 Рік тому

    thank you

  • @sarimisettyraghav4324
    @sarimisettyraghav4324 Рік тому

    nice bro jai hind

  • @onesrhaime6255
    @onesrhaime6255 2 роки тому +4

    please can you register your videos in english because we really need it

  • @seeyou7989
    @seeyou7989 2 роки тому +4

    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

  • @kenwom006
    @kenwom006 Рік тому

    thanks

  • @kashmirtechtv2948
    @kashmirtechtv2948 7 місяців тому

    But what if we don't want to show Navbar on Login?

  • @SumitSingh-wz3wt
    @SumitSingh-wz3wt Рік тому

    Bhaiya components useffect se pahele hi render nhi ho jayga

  • @rimi2419
    @rimi2419 5 місяців тому

    I have tries the same code but its not working

  • @thecodingplace
    @thecodingplace Рік тому +1

    This is not working. Getting error "Operation is unsecure".

  • @bhabanishankarrath6767
    @bhabanishankarrath6767 6 місяців тому

    But not working for me can anyone help

  • @mrnabby4178
    @mrnabby4178 Рік тому +2

    Thanks bro for saving my ass

  • @abdullahsoomro6238
    @abdullahsoomro6238 5 місяців тому

    WELL DONE 🟢

  • @dg_official96
    @dg_official96 Рік тому

    How access code

  • @adorablebabiesandpets2514
    @adorablebabiesandpets2514 Рік тому

    No protected route in English

  • @farheensayyed3604
    @farheensayyed3604 Рік тому +1

    ye work hi nhi ho raha sir

  • @mayankverma3684
    @mayankverma3684 Рік тому

    insta id ka link bhi add kiya karo description me