Тёмный
No video :(

Full React Tutorial #21 - The React Router 

Net Ninja
Подписаться 1,5 млн
Просмотров 503 тыс.
50% 1

In this React tutorial we'll talk about the React Router & see how to set it up so that we can have multiple 'pages' on our React websites.
🐱‍💻 🐱‍💻 Course Files:
+ github.com/iam...
🐱‍👤🐱‍👤 JOIN THE GANG -
/ @netninja
🐱‍💻 🐱‍💻 My Udemy Courses:
+ Modern JavaScript - www.thenetninj...
+ Vue JS & Firebase - www.thenetninj...
+ D3.js & Firebase - www.thenetninj...
🐱‍💻 🐱‍💻 Helpful Links:
+ HTML & CSS Course - • HTML & CSS Crash Cours...
+ Modern JavaScript course - • Modern JavaScript Tuto...
+ Get VS Code - code.visualstu...
🐱‍💻 🐱‍💻 Social Links:
Facebook - / thenetninjauk
Twitter - / thenetninjauk
Instagram - / thenetninja

Опубликовано:

 

21 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 208   
@danujajayasuriya9438
@danujajayasuriya9438 Год назад
it should be noted that starting from react-router-dom v6, has been replaced by .
@davidbryanramboy5043
@davidbryanramboy5043 Год назад
Is that only new changes that tackle from the video?
@chasec4897
@chasec4897 Год назад
​@@davidbryanramboy5043 I had an error that a private route couldn't be used in short term, the solution was to make the links as the below: }>
@davidbryanramboy5043
@davidbryanramboy5043 Год назад
@@chasec4897 singleton only
@chasec4897
@chasec4897 Год назад
@@davidbryanramboy5043 discovered that a few moments later
@melissacouturier5644
@melissacouturier5644 Год назад
Thank you! was wondering!!
@jeremy2217
@jeremy2217 2 года назад
Good work as usual ! For V6 of react-router-dom use instead of and place your componant inside an element attribute import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
@dobrealexandru1776
@dobrealexandru1776 2 года назад
Hi , i want to place html in Route , how can i do that?
@nikhildhakal3727
@nikhildhakal3727 2 года назад
​@@dobrealexandru1776 Don't do that. Make that html into a component and
@vidblogger12
@vidblogger12 2 года назад
Gotta love front end development, where even a tutorial from 1 year ago is already outdated, and 3 new JS frameworks were released in the time it takes you to watch that tutorial! :D
@alucard8678
@alucard8678 2 года назад
was just about to comment this
@oho6786
@oho6786 2 года назад
ty
@neilcartwright6369
@neilcartwright6369 3 года назад
If there's a better course on React I'd love to see it. Clear, concise, thoroughly brilliant.
@hank91918
@hank91918 3 года назад
it doesn't exist, this is as good as it gets!
@ejay
@ejay 2 года назад
Dev Ed's is pretty great
@samart3010
@samart3010 2 года назад
Codevolution reactjs playlist is also brilliant
@dlegand4951
@dlegand4951 2 года назад
scrimba react boot camp
@effiemmanuel1927
@effiemmanuel1927 2 года назад
This is the best React Crach Course on RU-vid ngl! For react-router-dom V6 you can use something like this:
@i_am_human_being5570
@i_am_human_being5570 3 года назад
This person makes learning so easy. Specially because the tutorials are of short length.
@darexleon
@darexleon 2 года назад
Nice! For v6 I used this code:
@mohitgangwani6054
@mohitgangwani6054 Год назад
it worked.thanks
@gabrielenguidanos7690
@gabrielenguidanos7690 7 месяцев назад
You're the godfather of tutorials. Concise, clear, perfect
@NetNinja
@NetNinja 7 месяцев назад
Thanks Gabriel! :)
@sueholder703
@sueholder703 3 года назад
8:00 explains how a React application is delivered to a client compared to a non-react website. So nice to get that understanding.
@sertacekici3342
@sertacekici3342 3 года назад
When I need to learn something about react you add a video about it. Thank you so much
@druludwig
@druludwig 3 года назад
Thank you for so often explaining the "why" behind what you're doing
@azeezismaila846
@azeezismaila846 2 года назад
Thank you so much, I only just started react 2 days ago and you have given a wide grasp of it. You make it so fun
@NetNinja
@NetNinja 2 года назад
Glad you're enjoying it! :)
@heavydirtysoul1491
@heavydirtysoul1491 3 года назад
When I need to learn any new technology about web development I go straight to this channel and check for a tutorial. Most of the times I learn it from here firstly. It is a great channel.
@martiananomaly
@martiananomaly Год назад
For people who want to use react-router-dom v6.X, Make the import statement: import { BrowserRouter as Router, Route, Routes} from 'react-router-dom'; and make the JSX:
@OdessaSenpai
@OdessaSenpai Год назад
Thank you for this hope he pins this
@ayisiree
@ayisiree Год назад
@@OdessaSenpai Thanks for this. I had a blank screen for 20 minutes
@Ancient244
@Ancient244 11 месяцев назад
instead of router use BrowserRouter
@michaelcapone8913
@michaelcapone8913 Год назад
Wow ! The first 3 minutes when you explained how react works is just amazing.
@PrashantAmoli
@PrashantAmoli 3 года назад
Hey Ninja, great tutorial and explanation🙏. I feel like you are the tutor I was searching for all this time on RU-vid. Your way of teaching is effective for me and the tutorials are just what I have planned to learn. Keep up the good work👍 and keep updating old tutorials like you you did here with functional programming in React. Super excited to learn a lot from you💯.
@martinrombach2666
@martinrombach2666 2 года назад
You're the best introduction I've had on React, out of 4. Good job man, you really know how to teach :)
@whatnowZA
@whatnowZA 2 года назад
Sticking with version 5 was smart because version 6 removed Switch for Routes. Thanks for the turorial.
@raphaelfreitas4565
@raphaelfreitas4565 2 года назад
A big thank you from Brazil 🇧🇷 !!! Great explanation and demonstration...
@NetNinja
@NetNinja 2 года назад
Thanks, hope it was helpful!
@dannyman2200
@dannyman2200 3 года назад
Loving this playlist, clearing up so many things
@jayanspaliwal5907
@jayanspaliwal5907 Год назад
Update for react router 6: use instead of what's in the video @The Net Ninja kindly pin this comment so that people don't search through the entire comment section for answer. Thank you
@randomthings1300
@randomthings1300 Год назад
Those who are using react-router-dom v6, please note some syntax change in the routing part- Switch has been removed and Routes have been introduced in place of that. refer below snippet please
@baro1620
@baro1620 Год назад
what if i want to add into first route for example and ?
@randomthings1300
@randomthings1300 Год назад
@@baro1620 Then you can add another route for Auth path say path="/user/auth" and element as e.g.
@randomthings1300
@randomthings1300 Год назад
@@baro1620 However if you want to force user to Login page all the time when they are not logged in to application and once they login they should be able to create Then you have to have a mechanism to detect is user Authenticated and then allow to access to application accordingly This will ensure user is forced to login page if not logged in
@labmember0045
@labmember0045 Год назад
Thanks buddy appreciate it
@legendaryknight6462
@legendaryknight6462 2 года назад
Shaun , u are so amazing . I love the way u explain everything . There is no body on earth who can do like what u do . I can not explain my feelings really . for about 2 years what ever I watched from your channel was the best of the best and how intelligently u plan to explain and make step by step guides in a very understandable way is so wonderful. I will be for ever member of this channel and will tell everybody u are my Hero. This channel worth 1 billion subscribers. Thank you Shaun ❤🐱‍👤❤.
@Sohanjs
@Sohanjs 7 месяцев назад
For react-router-dom v6 onwards: import { BrowserRouter as Router, Route, Routes } from 'react-router-dom'; Switch has been replaced by Routes and the Routes component requires that its children be either a or a . In version 6, the element prop is used instead of nesting components directly. The element prop takes the JSX element to render for the specified route.
@_itshenry
@_itshenry 6 месяцев назад
Do i need to save pages as .JSX or i could still use .JS
@soulju9144
@soulju9144 Год назад
We've been studying react for the past couple weeks with a test in a couple days. Definitely thought I was going to fail but you've given me hope! Lol. Thank you
@andredesantana2188
@andredesantana2188 3 года назад
Shaun you are a LEGEND!!! THANK YOU SO MUCH FOR THE AMAZING TUTORIAL!!!!!!
@tomaszswiatek4612
@tomaszswiatek4612 3 года назад
You may need to restart react by write in terminal "npm start" to proper run react-router:). Thx Shaun again for next lessons:)
@musaabdalwahed5645
@musaabdalwahed5645 3 года назад
Thank you ninja for this great effort.
@yyyooohhhooo
@yyyooohhhooo 3 года назад
Man.. this is clearer than crystal. thank you!
@user-ih5qg6xc7n
@user-ih5qg6xc7n 2 месяца назад
Thanks Net Ninja for this content also thank to this community who posted how to achieve same in V6.. Thanks
@uhyahaa8371
@uhyahaa8371 3 года назад
Oh boii.... the best tutorials on yt. thanks mate
@nipunamunasinghe
@nipunamunasinghe Год назад
Thank you so much! I explored a lot websites to learn how to use routes. Finally I found this video. Thank you so much!
@alanproduction910
@alanproduction910 Год назад
why doesn't work for me?
@trantrungnghia9642
@trantrungnghia9642 6 месяцев назад
if you don’t double check to see if you have liked this guy’s videos or not, you are a criminal
@lollilolli4582
@lollilolli4582 2 года назад
Listening your course is not boring for you have such a pleasant voice , thank you xaxa :)
@akhrorbekabdukhamitov8872
@akhrorbekabdukhamitov8872 2 года назад
for those who are using react-router-dom V6 your code should look like this
@dobrealexandru1776
@dobrealexandru1776 2 года назад
What about placing html functions like or , how can i put that in Route?
@danialranjbar9805
@danialranjbar9805 2 года назад
Thank u for ur efforts for building all these great tutorials. Thank u
@Ivan-Shyriaiev
@Ivan-Shyriaiev Год назад
Solution if you have problem such as [Home] is not an element or import {BrowserRouter as Router, Route, Routes} from 'react-router-dom';
@yashprog1359
@yashprog1359 Год назад
Thank you! 😊
@engahd746
@engahd746 3 года назад
U can use too
@ridl27
@ridl27 3 года назад
preffered way for me.
@arturdeandrade7443
@arturdeandrade7443 3 года назад
It does simplify things, but if you plan to pass any props to the component , it seems to be easier when it's nested. I'm still learning though, so I might be wrong about this.
@fjohanssondev
@fjohanssondev 3 года назад
The preferred way is to use the children method (as shown in the video). One thing to notice is that by using component={Whatever}, it will trigger React to create a new component for each render. Instead of updating the existing one. Also, I think the "to" prop is mostly used within links (Link, NavLink and such). While "path" is mostly considered to be used within the . I don't know if there's any difference using "to" within , does the "exact" prop work in that way?
@ridl27
@ridl27 3 года назад
@@fjohanssondev nah, its also "path", not a "to" attribute. He did a typo. And now I need to make research about component={Whatever}. Never thought that it could trigger React to create a new component for each render..
@therichardchannel
@therichardchannel 3 года назад
@@arturdeandrade7443 How do you pass props if it's written in this non-nested way?
@candle-likeghost9523
@candle-likeghost9523 3 года назад
aliasing when destructuring When import: { Aaa as Garbage } When assign variable : { Aaa : Garbage } WHy?
@ArnoldsKtm
@ArnoldsKtm 2 года назад
because object assignment operator is ":" import deconstructors are not objects per see and "as" is an alias operator long story short - deal with it
@CodeRCreatives
@CodeRCreatives 3 года назад
Thank you for this awesome react series.
@rabitebibi
@rabitebibi 3 года назад
Always at the top. Updated, and explained so ..... thx.
@ameyapatil1139
@ameyapatil1139 3 года назад
Wow this one was so so clear !! Excellent job
@sanjaycosmos9547
@sanjaycosmos9547 9 месяцев назад
Thanks man for clear explanation 🙌
@NetNinja
@NetNinja 9 месяцев назад
No problem 👍
@ayushman_sinhaa
@ayushman_sinhaa 2 года назад
Thank you so much for this video ! It really helped me get a clear understanding of React Router
@balakiswe
@balakiswe 3 года назад
This is some excellent skills to explain in that simple way.... cheers...
@sameerpokharel3531
@sameerpokharel3531 3 года назад
thank you Net ninja You're the Best Teacher
@mehrabmehmood7874
@mehrabmehmood7874 2 года назад
Thank you for this Great Series. So much simplified and very well explained.
@NetNinja
@NetNinja 2 года назад
Glad it was helpful! Thanks Mehrab :)
@omarshoura6327
@omarshoura6327 2 года назад
amazing job. Simple and to the point
@IndunilUdayalal
@IndunilUdayalal 3 года назад
This is a great video. Thank you very much.
@ramakrishnarudraraju6948
@ramakrishnarudraraju6948 2 года назад
Great Video. Straight to the point.
@halitsalihoglu4536
@halitsalihoglu4536 2 года назад
Now I understand React thanks man :)
@viniciusm.m.7822
@viniciusm.m.7822 2 года назад
This video is beautiful! Obrigado, brother! Deus abençoe!
@MaybeKian
@MaybeKian 2 года назад
great tutorial man, typescript + react would be really helpful too!
@Cdswjp
@Cdswjp 2 года назад
Thanks. It would be awesome if you created a video that shows how to use more than 1 bundle.js file in a project.
@danalex2991
@danalex2991 2 года назад
Brilliant Explanation
@henterpeter4806
@henterpeter4806 3 года назад
Hi @theNetNinja. Does the way React handles routing mean that at the initial request the server returns all the possible content to the browser, and then React sorts out locally what to show to the user? In case of complex websites this can be quite a lot of data, couldn't it? What can be done, so that users don't have to wait for too long before the landing page gets rendered?
@codymccarty9327
@codymccarty9327 2 года назад
I was wondering this same thing! It can't be the case, bc netflix uses react and they don't send every show they have everytime I open the app.
@user-sg4ek2dd3h
@user-sg4ek2dd3h 2 года назад
Thank you! Helped a lot 👍
@md.ashrafulalam7533
@md.ashrafulalam7533 3 года назад
please also make another tutorial using react and firebase
@KevinMullarkey
@KevinMullarkey 2 года назад
Brilliant tutorial Shaun, very clear voice and you explain everything clearly and easily.....but 'rowt' instead of 'root' for an Englishman!? I assume is for the American audience ;)
@NetNinja
@NetNinja 2 года назад
Haha, good spot. I think my accent confuses them enough, gotta throw some native pronunciations in there occasionally :)
@Arjun8BPCracker
@Arjun8BPCracker 3 года назад
Daymnnn that's the easiest explanation to this!
@jamesmuriuki3785
@jamesmuriuki3785 3 года назад
Thanks Ninja, coming back to React and this has made it so simple to level up!!!
@CleverCpp
@CleverCpp 2 года назад
thanks you very much from algeria
@NetNinja
@NetNinja 2 года назад
You are welcome! Hi to Algeria :)
@cruickshankatc
@cruickshankatc 6 месяцев назад
Great video! Thank you!
@NetNinja
@NetNinja 6 месяцев назад
Thanks for watching! :)
@digitalpartner7598
@digitalpartner7598 2 года назад
please mate you are the best , your method is the best , i learned a lot from you, would you please add a full MERN stack tutorials, it would be gentle , thanks
@vladimirputindreadlockrast812
As a beginner, React errors are frustratingly not well documented, IMO. My React app blew up after I ran the react-router-dom as described in this video. After a couple days of research, then giving up, then coming back to this video, I think I managed to fix it: 1) Uninstall Node.js on my Windows 11 machine. 2) Reboot 3) Fresh install Node.js 20.2.0 4) react create-app dojo-blog 5) enter dojo-blog folder 6) npm run start 7) npm install react-router-dom@5 8) npm json-server --watch data/db.json --port 8000 ...and my app is working without errors. As you can see, I did things a little out of order, swapping steps 7 & 8. I think the real fix here may have been the newest Node version, 20.n.
@basilm.b8499
@basilm.b8499 8 месяцев назад
In recent versions of react-router-dom, the Switch component has been replaced by Routes function App() { return ( ); }
@nihatbastan5561
@nihatbastan5561 7 месяцев назад
Thank you man!!
@dannyman2200
@dannyman2200 3 года назад
Obviously Node does a lot more, BUT in terms of handling requests does this router aspect of React negate Node and Express making them unnecessary for React apps ?
@tarekghosn3648
@tarekghosn3648 2 года назад
i feel every message should be written differently but over all thank you
@xdotli
@xdotli 3 года назад
Jesus it is so well explained.
@reinhardheydrich314
@reinhardheydrich314 3 года назад
thank u , this help me a lots love u :D
@afrikanking4022
@afrikanking4022 2 года назад
New Sub here... I love how you teach found you today
@Manozkirati
@Manozkirati 3 года назад
Was waiting... thanks..
@masaocodes
@masaocodes 2 года назад
Nice tutorial!
@younesbav0up316
@younesbav0up316 2 года назад
well explained thank you sir
@STUPIDYOUTUBE_HIDINGMSGS
@STUPIDYOUTUBE_HIDINGMSGS 2 года назад
So this ROUTE component, how will that affect and clash with the NODE.js routing if you're doing a MERN application? Which one wins, react router or Node router?
@architdutt
@architdutt 3 года назад
Simply amazing
@klirmio21
@klirmio21 Год назад
I just love you bro Why do people pay for courses? If there's such brilliant free tutorials by godsent people like you? thank you! love frm Ukraine
@neo90sr
@neo90sr 2 года назад
I have an error with switch. Attempted import error: 'Switch' is not exported from 'react-router-dom'. Does anyone know how to solve this? Looks like switch is not used anymore
@neo90sr
@neo90sr 2 года назад
I found the solution on stackoverflow. In the new react version, "switch" is replaced by "routes" and the component you want to render is inserted inside the "route" as a prop. Also "exact" is not required anymore.
@VTechBroLive
@VTechBroLive 2 года назад
@@neo90sr Thanks
@piekeheijmans7472
@piekeheijmans7472 3 года назад
allright then gang
@GiancarloCarccamo
@GiancarloCarccamo 2 года назад
great video
@andromilk2634
@andromilk2634 5 месяцев назад
Could you have called your home route instead of "/", for example, "/home"? Is this just a convention to begin your initial page only with a forward slash?
@nandopookey9195
@nandopookey9195 2 года назад
Thankyou very much sir
@jelouche
@jelouche 2 года назад
Small update with react-router-dom, Switch is not longer the keyword to place routes inside your application. Instead use Routes.
@ericmomoh7927
@ericmomoh7927 2 года назад
Watch the video from the beginning he stated something. That is because the time of doing the tutorial router version 6 was in beta mode so he chooses to use version 5 router which was stable then. Always watch video thoroughly before making comments. Cheers mate.
@jelouche
@jelouche 2 года назад
@@ericmomoh7927 @Eric Momoh bruhh, i think you should read the comments carefully yourself first. I said update as in there is a new update. I myself was figuring out the new syntax for couple of minutes. So I commented so it might help someone as it is one of the most popular tutorial video on react. Cheers 🥂
@nischalmohan2409
@nischalmohan2409 3 года назад
A question about BrowserRouter as Router. What is the difference between that and Say " { data: blogs,.. } ?
@subee128
@subee128 Год назад
Thanks
@maximk7816
@maximk7816 3 года назад
May I ask you some thing? If I show/hide components by routing does it make the same effect as mounting/unmounting components? I mean, in terms of rerendering?
@donbigosso
@donbigosso 2 года назад
So f**king clear! Thanks!
@stephenmuchara6696
@stephenmuchara6696 11 месяцев назад
just in case someone revisits here router V6
@m4cdemos
@m4cdemos Год назад
Many thanks for all your hard work - as a Brit, I can even (just about!) forgive you for pronouncing it 'rowt' instead of 'root'.... We already have to spell 'color' incorrectly, surely there's no need to speak 'US English' as well 🙄🙂
@bennyxfoo
@bennyxfoo 2 года назад
Thank you for the excellent tutorial. I am trying to convert my website to a react website. I use the traditional tags to route between pages and within pages. I am trying to use but it doesn't seem to work with "#id" eg. in the same page or on another page. It works ok with and . I am not sure what I am missing. Should I just stick with tags instead of . Would appreciate some help.
@Zangief001
@Zangief001 Год назад
Thank you so much!
@NetNinja
@NetNinja Год назад
You're welcome Jam! :) hope it was helpful
@user-nj1jj3xw2z
@user-nj1jj3xw2z 6 месяцев назад
super, danke
@eanonuevo
@eanonuevo 2 года назад
I got 'Error: Failed to compile'. I need to import 'import React from 'react' in every JavaScript files that uses JSX. For it to compile successfully
@drhastings
@drhastings 3 года назад
i keep wondering why people dislike tutorials, Why ??
@marcinmaj3609
@marcinmaj3609 3 года назад
Refresh react redux too with hooks
@dobrealexandru1776
@dobrealexandru1776 2 года назад
How do i use html in Route ? i can t just put in there cus it says that [p] is not a component
@theobellash6440
@theobellash6440 2 года назад
How do you lazy load component when a route is first activated ?
@yonasg9681
@yonasg9681 Год назад
sweet!
@nithinkharvi
@nithinkharvi 2 года назад
Vue3 and react look similar now
@moathdw910
@moathdw910 3 года назад
What is the best way to handle routes with auth?
@perschonca
@perschonca 2 года назад
If i finish all of these videos, will i be a net ninja?
@NetNinja
@NetNinja 2 года назад
Yes. Officially 😃
@perschonca
@perschonca 2 года назад
@@NetNinja Hell yeah, I'm going to need to buy a shirt if it's official. Thank you for your hard work
Далее
Full React Tutorial #22 - Exact Match Routes
5:24
Просмотров 242 тыс.
React Router - Complete Tutorial
23:53
Просмотров 105 тыс.
Əliyev və Putin kilsədə şam yandırıblar
00:29
Просмотров 198 тыс.
How To Master React In 2024 (Complete Roadmap)
13:30
Просмотров 187 тыс.
You might not need useEffect() ...
21:45
Просмотров 157 тыс.
The Story of Next.js
12:13
Просмотров 565 тыс.
WTF Do These Even Mean
13:44
Просмотров 83 тыс.
Most Beginner React Developers Do This Wrong
13:47
Просмотров 230 тыс.
Every React Concept Explained in 12 Minutes
11:53
Просмотров 568 тыс.