Full React Tutorial #23 - Router Links

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ม.ค. 2025

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

  • @unseenunspoken8413
    @unseenunspoken8413 2 ปีที่แล้ว +27

    I hardly jump in the comments section. Probably, this is my 4th or 5th comment on a TH-cam video for past 6 six years.
    First of all, I would like to thank you from the bottom of my heart for providing such great content free of cast over youtube. I'm a junior dev in the industry and writing plain HTML, CSS and JS for past 8 months. { For Laravel templating}. Right now, upgrading my toolset on React and Next.
    I'm learning alot from your TH-cam videos. I can't express enough that how thankful I'm to you at this stage of my carrier. People like you are hard to find. You are a gem in teaching and you must be proud on that.
    Keep guiding and enlighting us. We love you 💕

    • @NetNinja
      @NetNinja  2 ปีที่แล้ว +10

      Comments like this mean so much to me, thanks for your support :)

  • @maskman4821
    @maskman4821 4 ปีที่แล้ว +66

    summary of react router links (frontend routing, intercept the request and handle router in browser)
    1. import { Link } from 'react-router-dom'
    2. use

    • @adhanslv
      @adhanslv 11 หลายเดือนก่อน

      why doesn't work on me? i already install package react-router-dom

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

    This man is the GOAT of TH-cam programming tutors

  • @awhitechilliify
    @awhitechilliify 4 ปีที่แล้ว +12

    That moment when you want to hit Like button but you already have.. 🙈
    thank you so much Shaun!! ⭐️

  • @MiM-hh8xz
    @MiM-hh8xz 2 ปีที่แล้ว +38

    Great videos, Shaun! For some reason it didn't work for me using react-router-dom v5. I upgraded to v6 and got it working with this code (Note 'Switch' replaced by 'Routes' in V6 :

    • @Mong-Yun_Chen_54088
      @Mong-Yun_Chen_54088 2 ปีที่แล้ว +5

      ya, react-router-dom v5 is conflict with react v18.0.0,
      google 「React 18: react-router@v5 is breaking in the Strict Mode」。
      you can upgrade the react-router-dom, or downgrade the react back to 17.0.1.

    • @millzieme
      @millzieme 2 ปีที่แล้ว +1

      Thanks for this! Was also struggling with getting different page to render

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

      Thanks! You literally saved me potential hours of research

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

      Thanks a lot bro :)

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

      React 18 is probably not comptabile with reac-router-dom v5. path was changing but content weren't rendering in my case.
      update react-router-dom to v6, plus changing above two lines worked for me.

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

    At least you can still style the tags since they are rendered on the page as tags, thanks for the tutorial!

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

    This is exactly what i needed for my pages!

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

    This guy is not a ninja, he has become the master!!!!

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

    I have been finding react routers a bit difficult to learn, u just make it seem sooooo easyy

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

      Cool, I'm glad you're finding this helpful :)

  • @codedynamics1
    @codedynamics1 3 ปีที่แล้ว +22

    Shaun i think you might have forgotten that you wrapped the fetch inside a setTimeout and the setTimeout was just to simulate a server request. If you remove the setTimeout you dont get that error @ 2:53 and the links are 10 times quicker

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

      yeah, you are right!

    • @yichen8884
      @yichen8884 3 ปีที่แล้ว +5

      But in reality, fetch does take time to process.

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

      I can't reproduce the error, and I had my timeout set to 2000 ms :D

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

      nah bro. In reality you dont know what you get. So be prepared

  • @vinronra8758
    @vinronra8758 2 ปีที่แล้ว +4

    Hey Shaun, Thank you so much for the tutorial. I followed all your tutorial. In this particular video tutorial, at 2:52 , I didn't get the same warning message like you got on the console. I followed this tutorial from the start to end and my code are exactly the same as yours. Could you please explain to me why I didn't get the same warning on the console screen? Is this because I'm on newer version of react and they fixed this "memory leak" under the hood? My react version is 18.1.0

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

      I can't make the warning message appear either.
      I'm using
      "react": "^18.2.0",
      "react-dom": "^18.2.0",
      "react-router-dom": "^5.3.3",
      "react-scripts": "^5.0.1",

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

      most likely. i'm not encountering the warning message as well.

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

    simple and to the point, just subscribed

  • @PiotrMajdykowski
    @PiotrMajdykowski ปีที่แล้ว +4

    In react router-dom v6 it will be: function App() {
    return (











    );
    }
    export default App;

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

    Hello @The Net Ninja. I have a question please.
    When i clicked quickly the home then create links on the site, the my react app did not give me an error.
    could this be a new update to react or its something else??
    I would really appreciate your feedback

  • @azuko23
    @azuko23 2 ปีที่แล้ว +6

    Hi.. thanks for your awesome teaching~! Much much appreciate that. Just a question.. I followed your steps but in navbar links, they are not loading the respective components. If I refresh the page, I can load once. It fails in subsequent times. There is no error. Any idea how to fix it? I m using react-router-dom 5 too.

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

      Same here, I think it has to do with the fact that he's using an older version of React (React 17), while we are using React 18.
      if you find a fix please let me know.

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

      @@mehamdiamohamedamine4445 i upgraded react-router-dom to v6.. and swap to and switch to element (you can read on react router dom official blog about upgrading from v5).. now it s working.

    • @mehamdiamohamedamine4445
      @mehamdiamohamedamine4445 2 ปีที่แล้ว +1

      @@azuko23 thank you

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

      @@azuko23 i was having the same issue, thank you

    • @Mong-Yun_Chen_54088
      @Mong-Yun_Chen_54088 2 ปีที่แล้ว +2

      @@mehamdiamohamedamine4445 ya, I use the React 17, then it work.
      I google that there's a conflict between React 18 and rea-router-dom 5:
      「React 18: react-router@v5 is breaking in the Strict Mode」
      Download the files "index.js" and “package.json” that Net Nija upload at github, ( chose the lesson 23 branch, so your packages will be the same environment,)
      and replace these two files with yours.
      Then key command 「npm install」,
      then your 「React」should downgrade to 17.0.1.
      My Link finally work~
      this bug waste my whole day!

  • @channel23653
    @channel23653 4 ปีที่แล้ว +1

    So easy to follow and understand.Thank you

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

    This is such a good tutorial. Thank you.

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

    i think it;s a dumb question and surely i`m missing something from the past videos, but always getting the data from local, won't prevent getting new things from the server, changes on articles for example ?

  • @akshaysrivastava4304
    @akshaysrivastava4304 2 ปีที่แล้ว +6

    Fix !! React not working with react-router-dom v 5
    So upgrade it to v6 by stopping the react start and entering this,
    "npm i react-router-dom@6".
    Then make the following changes in Home.js,




    This should work, if not reply to this comment.

    • @linadai3930
      @linadai3930 2 ปีที่แล้ว +1

      I actually did the same thing. Hi, five!

    • @Anon-hj7il
      @Anon-hj7il 2 ปีที่แล้ว

      Thanks a lot, I was trying to look why is it not working for me 🤣

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

    TOP as usual!!!

  • @davidarthur6221
    @davidarthur6221 2 ปีที่แล้ว +1

    Mr. Shaun, thanks for this amazing video. But I have a problem. When I click on the link I have to reload the page to show the elements. Any help on this, please?

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

      I had the same issue and what I did was to change it back to a href

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

    great video man

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

    Super Awesome content! Thanks a bunch!

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

    This videos are awesome! Thank you!

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

    What's the best way to manage links when you have lots of pages. for example 10 pages have download link and you want to make sure if you update a link it will update all of the links for the downloads page

  • @nihallloyd3398
    @nihallloyd3398 4 ปีที่แล้ว

    How many episodes will be there for this new react tutorials. BTW great stuff man

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

    9 more videos to go... been working on this course for the last two days pausing and resuming as I worked along on my VS Code.

  • @jericarsolon8791
    @jericarsolon8791 9 หลายเดือนก่อน

    Hi! I have an error about the when I changed the anchor tag into Link and also href into "to" then it throws an error
    Uncaught Error: Invariant failed: You should not use outside a
    How to fix this?

  • @bluevine6957
    @bluevine6957 9 หลายเดือนก่อน

    Hi, the swicth while exporting it wasnt found in 'react-router-dom'

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

    Niiiice! Thank you!

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

    How do you deal with if you are putting your app on a subdomain. Getting React to know you are on a one?

  • @AkashKumar-it1mz
    @AkashKumar-it1mz 3 ปีที่แล้ว

    Hi @The Net Ninja, Love your videos on react and just wanted to know do I need to learn redux also for building modern applications. I just purchased your d3 course on udemy would also like to purchase a react and spring boot application eCommerce project on udemy

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

    You are number One. Ukraine watching!!!

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

    Incredible content! This channel is the 1-stop shop to anybody struggling with React. =D Cheers m8

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

      Glad you think so! :) that means so much, thanks

  • @SudeeptoDutta
    @SudeeptoDutta 4 ปีที่แล้ว

    Shaun, do you plan to make a video on Route Guards /Private Routes using react-router ?
    Basically the navigation flow if a normal user tries to navigate to an authorised route that they're not allowed to view ?

    • @NetNinja
      @NetNinja  4 ปีที่แล้ว +10

      I'll be making a separate series in the future about auth/react which will include this type of logic.

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

    Thanks a lot !

  • @MOHAMMED-qs2zn
    @MOHAMMED-qs2zn 2 ปีที่แล้ว +1

    i have a problem
    when i click on link i have to reload the page to show the elements

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

      Facing same problem here. Have you been able to have it fixed?

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

      @@davidarthur6221 updating "react-router-dom" to the latest version fixed it for me

  • @LavanyaKommana
    @LavanyaKommana 3 หลายเดือนก่อน

    I am not getting "cant perfrom react state update error"

  • @farhanamin4075
    @farhanamin4075 2 ปีที่แล้ว +1

    Bro what font you used in this project

    • @Anon-hj7il
      @Anon-hj7il 2 ปีที่แล้ว

      Its in the github repo

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

    You are amazing, the way you teach is very nice.

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

    I have a question. Let's say I make a complete website with lots of resources and stuff (maybe high quality pics), if I render the website with Router Links, does the site needs to be completely downloaded to local before it can be rendered? In this case it would be better to stick to regular routing? Thanks in advance to anyone who can help me! :)

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

      I have the same question. Did you found the answer?

    • @0xGrowth
      @0xGrowth หลายเดือนก่อน

      here cos of this comment.

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

    does anyone have a blank page while doing this dunno what's the problem

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

      I have the same Problem :/

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

    thank you so much

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

    Hey :) By this time i am using react-router-dom 6 and i get following warning in the console: "router.ts:11 No routes matched location "/""
    Can someone explain me this ?

  • @adelgafo7412
    @adelgafo7412 4 ปีที่แล้ว

    Thank you

  •  2 ปีที่แล้ว

    ADAMSIIIN

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

    Thank you, Shaun. First of all, I would apologize first since my English might make it difficult for you to understand me. I'm optimistic, that anyone out here helps me.
    Let me get to it, I have two or more parent components such as Users,
    Programs, Books, etc. And routes like /programs, /programs/new, /programs/:id, /programs/:id/edit, which seem to work but when I bring in /users, /users/add etc. Sometimes it works and sometimes it doesn't.
    Thank you for your help in advance.

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

    linking legends with new recruits

  • @ridl27
    @ridl27 4 ปีที่แล้ว

    ty

  •  4 ปีที่แล้ว

    Thanks

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

    I'm not getting that error in the end for some reason

  • @dangelgeek
    @dangelgeek 4 ปีที่แล้ว

    Hello, what is the solution so that this error does not appear?

    • @NetNinja
      @NetNinja  4 ปีที่แล้ว

      All explained in the next video of the series :)

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

      @@NetNinja this error doesnt seem to appear in mine and i have not cleaned up my custom hook lol. I didnt set my custom hook with a setTimer function. Is it because of that?

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

      @@VS257 Same, I also didn't create any setTimer function and it didn't show any errors

  • @eltoneycomerad8758
    @eltoneycomerad8758 4 ปีที่แล้ว

    awesome

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

    Can i make a question? Is it necessary to fetch the data again and again when we going to Home route ? I mean isnt it a waste because we have already load the data from the server! I am sorry if this is a dumb ques! I am stilk learning !

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

      Most probably you don't get this error because you are on your local server and don't have the setTimeout like he had.

  • @drhastings
    @drhastings 4 ปีที่แล้ว

    Mr Shaun ,When are you going to post angular tutorials

    • @fjohanssondev
      @fjohanssondev 4 ปีที่แล้ว +1

      You can look at Ben Awad's videos if you'd like some inspiration about AngularJS.

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

    Hello buddy excellent lesson as always! i have a question again! We write All routes of application in the App component? Ty in advance

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

    Level

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

  • @ckatke
    @ckatke 4 ปีที่แล้ว

    1st

  • @Mahmudulhasan-ts5hm
    @Mahmudulhasan-ts5hm 3 ปีที่แล้ว

    thanks

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

    Thanks