React Router Full Tutorial - ReactJS Beginner Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ต.ค. 2024

ความคิดเห็น • 84

  • @PedroTechnologies
    @PedroTechnologies  2 ปีที่แล้ว +3

    React router updated and I made an updated version of this video: th-cam.com/video/UjHT_NKR_gU/w-d-xo.html

  • @XavierSmithXcellence
    @XavierSmithXcellence 3 ปีที่แล้ว +2

    Thanks, Pedro, for a concise yet professional delivery of what can be a confusing concept. Good work!

  • @vapidfire68
    @vapidfire68 2 ปีที่แล้ว

    I am brand new to react and this is a great really clear primer for understanding the router. Thanks Pedro!

  • @cielocapalini
    @cielocapalini 3 ปีที่แล้ว +1

    Thank you again. All your tutorials are concise, yet so well explained. As a beginner to React and node, trying to convert my knowledge from PHP has been challenging, but your tuts have helped everything click into place.

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว

      Happy to hear :)

    • @sapnap2468
      @sapnap2468 ปีที่แล้ว

      hy , i think its been a year for you...I am looking for node js course can u suggest me any playlist which explain clear similar like him?

  • @pjguitar15
    @pjguitar15 3 ปีที่แล้ว +2

    Always appreciate your videos man. I learned a lot from you since I started going to React JS path. Now I'm started applying jobs. 🙏

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว

      Thank you so much! I am happy to see that i am helping you! Good luck on the job search, you will definitely get one soon!

  • @thilangajayarathne6575
    @thilangajayarathne6575 3 ปีที่แล้ว

    Thank you very much Pedro. It helps me a lot to understand the concept of routers very well.Your teaching skills are very attractive and i like the way you talk,once again thank you very much pedro,we want more tutorials

  • @nahiyanalislam8331
    @nahiyanalislam8331 3 ปีที่แล้ว +1

    brooooo, ngl but it's epic, really way better way of making understand than rest of the youtubers. Really appreciate it broo

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว

      Hahaha really appreciate it! Glad my videos are helping!

  • @play.7242
    @play.7242 ปีที่แล้ว

    Amazing completely needed what i want

  • @ricardocambundo2527
    @ricardocambundo2527 3 ปีที่แล้ว +1

    Thank you so much man
    Amazing tutorial, u earned a new subscriber

  • @ekoydakoykoy
    @ekoydakoykoy 3 ปีที่แล้ว

    to add, a typical implementation of useLocation is to do a scroll to top everytime a link is click. it is well documented in the react router dom API .

  • @ThColinPereira
    @ThColinPereira 3 ปีที่แล้ว +1

    Great video, Pedro! This helped me a lot.

  • @obafemilawal4199
    @obafemilawal4199 3 ปีที่แล้ว +1

    Am commenting from Python point of view about why they don't just call it BroswerRouter as you said... I haven't tried it either but when you use "as" it's just the same as the English word "as" let's call youtube as tube ... This means we giving it an alias so whenever we call tube we are actually referring to youtube.. So my point is you can also use BrowserRouter directly if you choose not to give it an alias .... I haven't tried this but am saying that's the point from Python's point of view which I think is the same here with javascript.
    Incase am wrong commenters please point me to the right direction.

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      Yeah your correct hahaha Its just cause its smaller and easier to right!

  • @MrChealsea007
    @MrChealsea007 3 ปีที่แล้ว +2

    It would be great if you could make one tutorial containing user roles (admin, moderator, normal user) . Admin can access everything, moderator cannot access admin page and so on. It would be so grateful. (On one of your videos, you have just made one user with dashboard)

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      Thank you for watching! I have another video where I show how to determine user roles based on a nodejs api. It should be the exact same thing to add those 3 roles. I can definitely make a video on restricting routes on react router dom!

    • @MrChealsea007
      @MrChealsea007 3 ปีที่แล้ว

      ​@@PedroTechnologies Actually, I do not handle the backend, and my task is to control the user roles in the front end. I am using react router dom for that. I will paste certain part of my code here. I hope you figure out what i am trying to do.
      Here is the switch part in app.js :
      const { userRole } = useUserInfo();





      {userRole === "admin" &&


      }
      {userRole === "moderator" &&

      }
      {((userRole === undefined) || (userRole === ' ') ) &&
      {console.log("undefined role entered")}


      }
      IN PROTECTED ROUTE :
      export default function ProtectedRoute({ role, component: Component, ...rest }) {
      //from userContext
      const { userRole, isLoggedIn} = useUserInfo();
      return (
      {
      //console.log(props);
      if (isLoggedIn) {
      return
      } else {
      return
      }
      }} />

      )
      }
      NOW; THE PROBLEM I AM GETTING IS :
      - when the user is not logged in, if i type localhost:3000/admin ==> AccessDenied component gets rendered
      -BUT, when i type, localhost:3000/randomtext ==> NOTHING GETS RENDERED (expected to render Home component)
      -when the user is logged in . same problem like above. (When moderator gets logged in, it cannot access admin, when admin is logged in, it can access everything. But, if random text is entered in the url, nothing gets rendered)
      So, that means, the last line is not executed.
      May be I am doing wrong inside Protected route, or I dont know what is the problem.
      I hope you got what I am trying to explain, and I hope you would give some idea to solve the problem :)

    • @MrChealsea007
      @MrChealsea007 3 ปีที่แล้ว +1

      @@PedroTechnologies Hey, I think I figured out one way of doing it.
      As I am using conditional (ternary) operator inside Switch, I think the tag inside that operator is not working properly. So, I tried adding extra tag inside those condition, and now I am getting expected output.
      I dont know if thats correct way. But, I am getting the output that I was expecting. Hope, it will help others also who is in the similar situation :D
      Here is the modified code below:




      {userRole === "admin" &&


      }
      {userRole === "moderator" &&

      }
      {((userRole === undefined) || (userRole === '') ) &&
      {console.log("undefined role entered")}





      }

  • @softafrica
    @softafrica 3 ปีที่แล้ว

    Awesome video. Loved it. I had to subscribe.

  • @deathdefier45
    @deathdefier45 2 ปีที่แล้ว

    Top knotch content bro you're a hero ❤️

  • @jakakrajnc7538
    @jakakrajnc7538 3 ปีที่แล้ว

    Pedro great video, liked and subscribed! #fire 🔥

  • @anjuyadav7013
    @anjuyadav7013 3 ปีที่แล้ว

    Loved it ...very nicely explained

  • @marufkhan23508
    @marufkhan23508 3 ปีที่แล้ว

    Hi Pedro, I have seen some blogs that people use a separate route.js file to keep track of all the routes. Can you make a video on it, please?
    * I subscribed 🎉😊

  • @himanshulal97
    @himanshulal97 3 ปีที่แล้ว +1

    this is for making comment count from 69 to 70, very well explained , but apart from this i have a ques that why u have used sublime text editor them in vsCode , again jokes apart well explaining thank u so much 😀😄

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว

      Thank you! I just used the theme from sublime, but it is still vscode!

  • @TheNamesJT
    @TheNamesJT 3 ปีที่แล้ว +2

    Next video teach everyone how to add advertising to there page in react.....its ridiculous how tough this is to do....amazon and google ads. Been trying for 3 days now.

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      Interesting! I actually have never implemented ads, but I can try it out! I thought google ads was straightforward, might have to check it myself.

    • @TheNamesJT
      @TheNamesJT 3 ปีที่แล้ว +1

      @@PedroTechnologies let me know if you figured it out cause i tried myself and can't seem to get the ad to display. If you want my code let me know cause youtube won't let me link anything in comments. Do you have a twitter?

  • @rangabharath4253
    @rangabharath4253 3 ปีที่แล้ว +1

    Awesome as always 👍😀

  • @parth-patel-software
    @parth-patel-software 3 ปีที่แล้ว +2

    Make video on styled components in react

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      I plan on making an update full styled components video, but at the time I have an older video if you want! th-cam.com/video/kKhQALrMtnU/w-d-xo.html

    • @parth-patel-software
      @parth-patel-software 3 ปีที่แล้ว

      Thanx for replay , your every stuffs are useful to me and i am spreading your stuff links to my dev community.

  • @rafikmansour4755
    @rafikmansour4755 3 ปีที่แล้ว +1

    Good Job Pedro

  • @nathangoel8894
    @nathangoel8894 3 ปีที่แล้ว

    Great tutorial

  • @STUPIDYOUTUBE_HIDINGMSGS
    @STUPIDYOUTUBE_HIDINGMSGS 2 ปีที่แล้ว

    Very simple and clear, thanks for this video, you are a star, Pedro, keep it up!

  • @radu9150
    @radu9150 3 ปีที่แล้ว +1

    Great content! 👏

  • @guptaAman7
    @guptaAman7 3 ปีที่แล้ว

    Great video, thanks.

  • @roselpadilla
    @roselpadilla 3 ปีที่แล้ว +1

    Amazing content, glad to be here before you 🚀

  • @shubamdadhwal3497
    @shubamdadhwal3497 3 ปีที่แล้ว

    Awesome video brother, one thing to point out is that:
    when we specify /:name & /* both in our route, only one out of them will work. Is there any fix for that?

  • @worldclasscode1847
    @worldclasscode1847 2 ปีที่แล้ว

    Great video !:)

  • @adelaionce
    @adelaionce 3 ปีที่แล้ว

    Thank you 💟

  • @leonardodayrell2976
    @leonardodayrell2976 3 ปีที่แล้ว

    Another good video! Thanks pedro

  • @kaungchitko7156
    @kaungchitko7156 2 ปีที่แล้ว

    Thank you very much

  • @dualwan
    @dualwan 2 ปีที่แล้ว +3

    i just found that react-router-dom v6 dont support Switch. is it wise to adopte the version 6, or stay in version 5?

  • @HTFGamesStudio
    @HTFGamesStudio 2 ปีที่แล้ว

    Thanks!

    • @PedroTechnologies
      @PedroTechnologies  2 ปีที่แล้ว

      Thank you for the support!

    • @HTFGamesStudio
      @HTFGamesStudio 2 ปีที่แล้ว

      @@PedroTechnologies thx you for saving me time :)
      By the way react has a huge problem for the fact of single page aplication that is made with javascript. So crawler bots responsabile for seo has problems of understanding the website. Bad seo means your website cannot be easely found in search engine like google.
      I suggest you to cover this topic coz there is no many video about it that really helps saving the problem

  • @softblood1941
    @softblood1941 3 ปีที่แล้ว +1

    instead of react router i prefer to use Next.js but its also a nice way

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      I really like next.js! I am actually thinking about making some sort of series on it!

  • @ekoydakoykoy
    @ekoydakoykoy 3 ปีที่แล้ว

    So for your useParams example , you add /:name in the home path and when u use a name similar to the other link eg. name = localhost/blog (we have a route with /blog) so basically it is overlapping. what could be your remedy here?

  • @ralphpanzullo2958
    @ralphpanzullo2958 3 ปีที่แล้ว

    What if you React app is on a subdomain? It will resolve to the root not the subdomain.

  • @mayurghuge8846
    @mayurghuge8846 2 ปีที่แล้ว

    Thanks.

  • @ravitejac3
    @ravitejac3 3 ปีที่แล้ว

    Good one. when I try the same I'm getting the error as 'TypeError: Cannot read property 'push' of undefined in react'. Is this code on latest React version?

  • @TrueHumanNature74
    @TrueHumanNature74 3 ปีที่แล้ว +1

    love from india

  • @anubhapant5227
    @anubhapant5227 3 ปีที่แล้ว

    Make videos on react projects

  • @hmsm5701
    @hmsm5701 3 ปีที่แล้ว

    Very good very good

  • @DeepakGupta-pz4fx
    @DeepakGupta-pz4fx 3 ปีที่แล้ว +1

    It would be happy please make on video redux crash course

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว

      Thank you! I actually don't code that much on redux so I wouldn't be able to make a series on it!

    • @md.siddiq7165
      @md.siddiq7165 3 ปีที่แล้ว +1

      @@PedroTechnologies what do you use for state management?

    • @PedroTechnologies
      @PedroTechnologies  3 ปีที่แล้ว +1

      @@md.siddiq7165 I use context API for most projects, if I need something extra sometimes I use MobX

    • @md.siddiq7165
      @md.siddiq7165 3 ปีที่แล้ว

      @@PedroTechnologies That's great. Thanks for the reply. I am a beginner in react. I love the simplicity of context. But I think you should also checkout Redux-toolkit. It removes almost all the nasty boilerplate of setting up redux. I haven't used mobx till now but will definitely check it out. Thanks

  • @rogeclash2631
    @rogeclash2631 ปีที่แล้ว

    is therer any code for this ? thanks

  • @abhaytiwari6411
    @abhaytiwari6411 3 ปีที่แล้ว +1

    Good

  • @PanlasangMotour
    @PanlasangMotour 3 ปีที่แล้ว +1

    NOICEEE

  • @zelmasedano5070
    @zelmasedano5070 3 ปีที่แล้ว

    Check your discord!!!

  • @minhluudinh5522
    @minhluudinh5522 2 ปีที่แล้ว

    .

  • @zm12123
    @zm12123 3 ปีที่แล้ว

    No one teaches how to use nested routing or creating dropdown menu's.... the documentation for react router is the worst ive ever seen.

  • @gelatinousPube
    @gelatinousPube ปีที่แล้ว

    I'm trying to follow this but things are not working for me. I look at the React Router Dom docs and they seem to explain an entirely different, and much more confusing way of needing to do all this.
    I'm a bit confused... it seems like you need to setup your root, then create a BrowserRouter and then add providers and things. Is that necessary? The video is much simpler but doesn't work for me... I just get errors and blank pages despite following these instructions hmm

    • @gelatinousPube
      @gelatinousPube ปีที่แล้ว

      sorry, it seems that some of the instructions in the video are out of date for v6 of react router dom, and instead of 'component' as a prop, you use 'element', and pass in the component as jsx rather than a function. This was my issue, also Switch is no longer used, and instead you seem to need to use Routes instead.