Full React Tutorial #21 - The React Router

Full React Tutorial #21 - The React Router

Net Ninja

3 года назад

472,638 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

James Draper
James Draper - 05.10.2023 14:43

hurts to hear a British man say router that way

Ответить
Stephen Muchara
Stephen Muchara - 23.09.2023 21:46

just in case someone revisits here
router V6

<Routes>
<Route path='/' element={<Home/>}/>
</Routes>

Ответить
Mishkat Hossain
Mishkat Hossain - 13.09.2023 06:26

What can I do now?? the current running version of react dom is 18. I googled it?? how do I install it??
can anyone help me???

Ответить
Ai Capitan
Ai Capitan - 22.06.2023 11:44

i have been sitting here for four fucking hours and have copied the code TOO THE T! and it just doesnt work. im fucked

Ответить
misery topskiy gg
misery topskiy gg - 15.06.2023 23:52

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

Ответить
NISHOK R R
NISHOK R R - 06.06.2023 05:41

can you guys tell me whats the font he is using?

Ответить
Vladimir Putin, Dreadlock Rasta
Vladimir Putin, Dreadlock Rasta - 27.05.2023 20:52

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.

Ответить
Ivan groźny
Ivan groźny - 02.05.2023 23:09

Solution if you have problem such as [Home] is not an element or <Route>

import {BrowserRouter as Router, Route, Routes} from 'react-router-dom';

<div className="content">
<Routes>
<Route path="/" element={<Home/>}/>
</Routes>
</div>

Ответить
Durga Prasad Vinukonda
Durga Prasad Vinukonda - 20.04.2023 05:34

Hi All,
All of sudden when I started installing router package in my machine . My npm not working . Throwing me proxy behind error. Although I have deleted proxy details but still facing issue . Can someone help me to fix this issue ?

Ответить
paul tester
paul tester - 07.03.2023 20:32

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 🙄🙂

Ответить
Random Things
Random Things - 27.02.2023 11:00

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

<Router>
<div className="App">
<Navbar />
<div className="content">
<Routes>
<Route exact path="/" element={<Home></Home>}></Route>
<Route
path="/create"
element={<CreateBlog></CreateBlog>}
></Route>
</Routes>
</div>
</div>
</Router>

Ответить
Soulju
Soulju - 11.02.2023 11:46

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

Ответить
Michael Capone
Michael Capone - 24.01.2023 00:46

Wow ! The first 3 minutes when you explained how react works is just amazing.

Ответить
subee128
subee128 - 05.01.2023 12:26

Thanks

Ответить
Yonas G
Yonas G - 10.12.2022 04:19

sweet!

Ответить
Alan Editor
Alan Editor - 21.11.2022 13:16

this tutorial doesn't work for me ! idk why ? can somebody help me please ?

Ответить
LEI WANG
LEI WANG - 28.10.2022 13:30

Thanks!

Ответить
AnonymousKitty
AnonymousKitty - 04.10.2022 23:36

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:

<Router>
<div className="App">
<Navbar></Navbar>
<div className="content">
<Routes>
<Route path='/' element={ <Home /> } />
</Routes>
</div>
</div>
</Router>

Ответить
Jayans Paliwal
Jayans Paliwal - 04.10.2022 15:00

Update for react router 6:
use <Route path='/' element={<Home/>}/> 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

Ответить
Jam
Jam - 24.09.2022 04:27

Thank you so much!

Ответить
Nipuna Munasinghe
Nipuna Munasinghe - 20.09.2022 19:24

Thank you so much! I explored a lot websites to learn how to use routes. Finally I found this video. Thank you so much!

Ответить
Danuja Jayasuriya
Danuja Jayasuriya - 04.09.2022 17:36

it should be noted that starting from react-router-dom v6, <Switch /> has been replaced by <Routes />.

Ответить
Tarek Ghosn
Tarek Ghosn - 08.08.2022 21:47

i feel every message should be written differently but over all thank you

Ответить
Raphael Freitas
Raphael Freitas - 06.08.2022 21:56

A big thank you from Brazil 🇧🇷 !!! Great explanation and demonstration...

Ответить
ould hennia Abdelkader
ould hennia Abdelkader - 04.08.2022 09:25

thanks you very much from algeria

Ответить
Azeez Ismaila
Azeez Ismaila - 01.08.2022 21:43

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

Ответить
Kevin Mullarkey
Kevin Mullarkey - 26.07.2022 12:03

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 ;)

Ответить
Mehrab Mehmood
Mehrab Mehmood - 21.07.2022 21:07

Thank you for this Great Series. So much simplified and very well explained.

Ответить
A7
A7 - 08.07.2022 02:21

Thank you! Helped a lot 👍

Ответить
Theo Bellash
Theo Bellash - 26.06.2022 21:04

How do you lazy load component when a route is first activated ?

Ответить
VIKRAnt MORe
VIKRAnt MORe - 26.06.2022 01:03

I am having an error for 'BlogList' Component and i.e. React must be in the scope when using jsx...can anybody tell me why is the happening & how to resolve it..please

Ответить
F G
F G - 24.06.2022 02:28

this guy sounds like he's from yorkshire

Ответить
Nando Pookey
Nando Pookey - 16.06.2022 20:23

Thankyou very much sir

Ответить
YOUNES BAv0UP
YOUNES BAv0UP - 14.06.2022 15:21

well explained thank you sir

Ответить
Darex Leon
Darex Leon - 09.06.2022 03:13

Nice! For v6 I used this code:

<Router>
<div className="App">
<Navbar />
<div className="content">
<Routes>
<Route path="/" element={<Home />} />
</Routes>
</div>
</div>
</Router>

Ответить
Patrick Pereira Vieira
Patrick Pereira Vieira - 01.06.2022 15:24

I got 6 high severity vulnerabilities after installing T_T

I tried doing it with version 5 first and then installed version 6. Still got the same vulnerabilities. Even by using npm audit fix and npm audit fix --force, it's the same. Anyone got a fix or shall i just continue with the tutorial?

Ответить
Vinicius M. M.
Vinicius M. M. - 15.04.2022 16:33

This video is beautiful!
Obrigado, brother!
Deus abençoe!

Ответить
Dobre Alexandru
Dobre Alexandru - 01.04.2022 12:57

How do i use html in Route ? i can t just put <p><p> in there cus it says that [p] is not a <Route> component

Ответить
Prashant S
Prashant S - 29.03.2022 20:21

How do you re direct from a function based on sone condition ?

Ответить
Ayushman
Ayushman - 22.03.2022 23:41

Thank you so much for this video ! It really helped me get a clear understanding of React Router

Ответить
Giancarlo Carcamo
Giancarlo Carcamo - 18.03.2022 20:09

great video

Ответить
What Now?
What Now? - 16.03.2022 18:53

Sticking with version 5 was smart because version 6 removed Switch for Routes. Thanks for the turorial.

Ответить
Masao Codes
Masao Codes - 08.03.2022 00:25

Nice tutorial!

Ответить
Jelouche
Jelouche - 02.03.2022 05:10

Small update with react-router-dom, Switch is not longer the keyword to place routes inside your application. Instead use Routes.

Ответить
Halit Salihoğlu
Halit Salihoğlu - 22.02.2022 17:33

Now I understand React thanks man :)

Ответить
Akhrorbek Abdukhamitov
Akhrorbek Abdukhamitov - 21.02.2022 13:41

for those who are using react-router-dom V6 your code should look like this
<Router>
<Routes>
<Route path='/' element={<Home/>} />
</Routes>
</Router>

Ответить
Jeremy
Jeremy - 19.02.2022 20:05

Good work as usual !

For V6 of react-router-dom use <Routes> instead of <Switch> and place your componant inside an element attribute

import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
<Routes>
<Route path="/" element={<Home />}></Route>

</Routes>

Ответить
Danial Ranjbar
Danial Ranjbar - 13.02.2022 13:21

Thank u for ur efforts for building all these great tutorials. Thank u

Ответить