React Router v6 in 20 Minutes | RRv6 Upgrade & Refactor Tutorial

Поделиться
HTML-код
  • Опубликовано: 13 июн 2024
  • Web Dev Roadmap for Beginners (Free!): bit.ly/DaveGrayWebDevRoadmap
    In this React Router v6 upgrade & refactor tutorial, you will learn about React Router v6 including how to upgrade from v5 while refactoring a React JS Blog project utilizing the new features of RRv6.
    🚩 Subscribe ➜ bit.ly/3nGHmNn
    🚀 React JS for Beginners full course - 9 hours: • React JS Full Course f...
    🔗 Starter Source Code: github.com/gitdagray/learn_re...
    🔗 Refactored Source Code: github.com/gitdagray/react_ro...
    React Router v6 in 20 Minutes | RRv6 Upgrade & Refactor Tutorial
    (00:00) Intro
    (00:09) Welcome
    (00:15) Look at the docs
    (01:07) The Starter Project
    (02:15) Installing React Router Version 6
    (04:05) Updating the Index.js
    (06:09) Updating the App.js imports
    (06:39) useNavigate replaces useHistory
    (07:26) Adding a Layout Component
    (11:35) Adding Outlet index content
    (13:40) Nested Routes
    (16:13) Additional Routes
    (17:04) Review of the Routing Structure
    (18:29) Link and useParams
    (20:20) Testing the Refactored Code
    🔗 ES7 React JS Snippets Extension for VS Code:
    marketplace.visualstudio.com/...
    🔗 React Dev Tools Extension for Chrome:
    chrome.google.com/webstore/de...
    📚 References:
    React Router: reactrouter.com/
    ReactJS Official site: reactjs.org/
    React Wikipedia: en.wikipedia.org/wiki/React_(...)
    React Jobs: www.ziprecruiter.com/candidat...
    ✅ Follow Me:
    Github: github.com/gitdagray
    Twitter: / yesdavidgray
    LinkedIn: / davidagray
    Blog: yesdavidgray.com
    Reddit: / daveoneleven
    Was this tutorial about the React Router v6 helpful? If so, please share. Let me know your thoughts in the comments.
    #react #router #v6

Комментарии • 123

  • @DaveGrayTeachesCode
    @DaveGrayTeachesCode  2 года назад +21

    Within a couple months of introducing my React JS for Beginners course, React Router released a new major version: React Router 6. The changes are great! But they were breaking changes for the blog project in my React JS for Beginners course. That gave a great opportunity for a video tutorial where the React JS blog is refactored with RRv6...this video! Consider this video a new chapter to the course that shows how to implement RRv6 instead of v5. Just starting with React? My React JS for Beginners course provides 9 hours of tutorials to help you level up: ruclips.net/video/RVFAyFWO4go/видео.html

    • @waseem4783
      @waseem4783 2 года назад +1

      Hey Dave,
      Just try this out.. Type --> rafce inside any .js file and press Tab this will auto complete it, and also check emmet is present and configured correctly.
      Thank You. You are awesome 🤩

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +2

      @@waseem4783 yeah I have heard, but it doesn't work for me. I do use Emmett daily so no issue there. I need to take the time to see what is preventing this in my settings. Thanks for the note.

  • @johnmcaulay4348
    @johnmcaulay4348 2 года назад +12

    I thought I was losing my mind when I installed React Router on a new project the other day and couldn't get anything to work, then I realised there had been a major update. Thanks for the run through!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +4

      I can see how that would happen. There are some big changes!

  • @dsacppracticequestion1123
    @dsacppracticequestion1123 10 месяцев назад

    Thanks Dave for this awesome updated video on RRv6.

  • @vladislavamarkova8379
    @vladislavamarkova8379 2 года назад +3

    Thank you so much, Dave! Best React tutorials and explanation of React Router 6. It is really heplful and gives me the passion to learn more!

  • @tetyanagon3342
    @tetyanagon3342 10 месяцев назад

    AWESOME tutorial, thank you Dave!

  • @beng2620
    @beng2620 6 месяцев назад

    Thank you so much for this refactor!

  • @harshithcsgundappa4942
    @harshithcsgundappa4942 11 месяцев назад

    Thanks for the refactor video man

  • @cristhiandavidgiraldosanch6159
    @cristhiandavidgiraldosanch6159 2 года назад

    Thank you so much. I was waiting for this video and you really helped me.

  • @mikeyo5154
    @mikeyo5154 2 года назад

    Excellent. Thanks for updating for react-router-dom V6. Very helpful

  • @jrmaiafs
    @jrmaiafs Год назад

    Thank you for this update. It will be very important in my project.

  • @xen0n20p7
    @xen0n20p7 6 месяцев назад

    Thanks man you the best ✌️🔥

  • @akimjohnson3506
    @akimjohnson3506 2 года назад

    Simple & precise explanation ty.

  • @jdundee20
    @jdundee20 7 месяцев назад

    For myself rafce works without the underscore. I am doing a paid course and when they got to the react section I finished it with little understanding of what I was doing and immediately paused the course to come back to your channel, so many may know the material but they don’t have the teaching skills you have 🤟

  • @eddieotudor9432
    @eddieotudor9432 2 года назад +1

    You're an amazing person! Thanks a lot for teaching me!

    • @eddieotudor9432
      @eddieotudor9432 2 года назад

      ...was able to wrap my head around the Routing but making use of links got me lol! I'm cool now, thanks!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      Glad I could help, Eddie! 💯

  • @CTILET
    @CTILET 2 года назад +1

    I began to learn react router. And the video is loaded in your chanel!

  • @nirajborkar4208
    @nirajborkar4208 Год назад +1

    useReducer hook was one of my nemesis while leaning React JS ;P but Thanks to you Dave Gray. Now it looks like a piece of cake. Awesome tutorials Dave. Keep up the good work :)

  • @anangyoga1381
    @anangyoga1381 Год назад +3

    I've been stuck for a while on video 16. but since I watched this refactor, I think I can continue to learn video 17, even though it might need a little bit of adjustment. thanks mr Gray!

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Год назад

      You can do it! 🚀

    • @ameyapotdar461
      @ameyapotdar461 6 месяцев назад

      @@DaveGrayTeachesCode hi dave, I am getting error of useRef even though I have done the Router Routes and Route correctly please help

  • @mohiminurrahman6487
    @mohiminurrahman6487 2 года назад

    Thank you sir .
    Waiting for this ... now its on air ..
    Tq sir ❤

  • @thewiscokid81
    @thewiscokid81 2 года назад

    Great update video.

  • @portiseremacunix
    @portiseremacunix 2 года назад

    hmmm, this channel is my go-to place for everything on HTML, CSS, JS and React etc...like a reference book. Thanks for your work!

  • @christopherpink842
    @christopherpink842 2 года назад

    Thank you , iwas doing your react course notcied about the router tried to understand the version 6, but had to use the version 5 to complete it. thanks for updating to version 6

  • @ahmad-murery
    @ahmad-murery 2 года назад +3

    Now that I have a very strong memory I think it will take some time for me to stop confusing the syntax of old and new router 😎
    Thanks for the update Dave,

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +2

      New versions always make us keep learning! Thanks for the comment my friend 🙏💯

    • @ahmad-murery
      @ahmad-murery 2 года назад +3

      ​@@DaveGrayTeachesCode so true, this is part of us,
      maybe this is why we choose to be developers,
      my only problem here is I have 4 hours of electricity to manage all sort of things in my life,
      so thanks for making it a bit easier to catch up my friend,

  • @zarefgamz2515
    @zarefgamz2515 Год назад

    you helped me a lot and saved me a lot of time

  • @abba3261
    @abba3261 2 года назад

    omg your chanal have everything i need

  • @Furki4_4
    @Furki4_4 Год назад

    I was about to freak out while watching React Routes in the React tutorial, thank you for updating the routes tutorial. I think this looks better and similar to the Angular Router :3

  • @mohamedyoussef8835
    @mohamedyoussef8835 2 года назад

    Awesome Tutorial +++++++++++++++++++++ Thank You

  • @arjaybet7415
    @arjaybet7415 7 месяцев назад

    nice video, 👍 but would be nice if you could have a version of migration of this using route config so that to compare it

  • @waleedreaper
    @waleedreaper 10 месяцев назад

    Hey Dave, I've found out that this works as well. Should I use this or not:
    Instead of useNavigate I just enclosed the submit button inside a Link tag that took me to the home page after adding the new post to posts.

  • @josuegarcia4280
    @josuegarcia4280 2 года назад +2

    Excellent video just like the rest of yours, I appreciate the knowledge you add to our mind, the only thing I did not see here is that the edit functionality was not included, is it maybe updated later in the course? I am at video #20 right now and I added it to the route but it does not display anything, I maybe added it wrong.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      Thank you, Josue! It has been a few months, but I thought everything was updated when I made this. You can download my source code to compare to yours.

    • @josuegarcia4280
      @josuegarcia4280 2 года назад +1

      Awesome, I just used the lines before as you had in the "post" section and used "edit/:id" instead of post and it worked just fine, if someone
      needs the code let me know I can share it

    • @kevinnguyen238
      @kevinnguyen238 Год назад

      @@josuegarcia4280 Hi Josue Can I see the code for the edit routes?

    • @wolodymyrsss6111
      @wolodymyrsss6111 7 месяцев назад

      @@DaveGrayTeachesCode You didn't include edit part. Could you include the peace of code for edit?

  • @GabrielMartinez-ez9ue
    @GabrielMartinez-ez9ue 2 года назад +1

    Mr. Gray, would you use react router or nextjs dynamic routing for big projects? I have never been a fan of react router due to how messy it can get.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      I really like the changes in React Router v6. I also think Next JS is excellent and look forward to covering it later this year. I think both are good choices, and you should go with what you are most comfortable with. 💯🚀

  • @IconicProps
    @IconicProps 2 года назад

    I really enjoy your content. A few months ago I learned Angular 12 as it seemed that is where things were going, and this month, it appears I need react.
    The position I accepted uses redux and immer. I think I ended up here following your 9hr full course tutorial, when the router section threw a bunch of errors (I am sure its a version thing) as I was going through it on the way to getting to the redux section at the end.
    The long / short question is do you have anything that shows how you would start to implement immer with redux?
    And
    Do you find react to be the simplest of the frameworks (Angular/Vue/React/Next). And what do you think of Nuxt?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +3

      Thank you! Redux now uses Immer.js "under the hood". I recently completed a Redux full course tutorial here: ruclips.net/video/NqzdVN2tyvQ/видео.html Immer also you to write code that would otherwise mutate state, but it handles it properly for you. I do like React and the modern application of Redux. I don't have enough experience with Nuxt to compare it. Next.js is something I plan to cover yet this year. 🚀

    • @IconicProps
      @IconicProps 2 года назад

      Thanks so much. I was stuck in the amgularjs world until recently and your videos have been really valuable getting up to speed for a position I accepted.
      I did a few side projects in angular 12 which was a little verbose but I was able to pick it up faster than react. Ive been struggling with some of the concepts for the immutable data store techniques. I was feeling really frustrated until I found your videos.
      I really appreciate what it takes to keep these updated. As well as the attention to detail and patience required to express complex ideas in a simple and consumable way. So thank you kindly.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      @@IconicProps you're welcome! 🙏

  • @fkbey5756
    @fkbey5756 2 года назад

    thanks. wish i would be a student where you are teaching in university. I hope, your students aware of having a best programming teacher in the planet.

  • @wolodymyrsss6111
    @wolodymyrsss6111 7 месяцев назад

    I repeated exactly, everything run successfully but unfortunately received this
    Matched leaf route at location "/" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.
    What might be the correction?

  • @gaotrunguyen
    @gaotrunguyen Год назад

    Hi Dave, please check Path intellisense or visual studio intellicode plugin out. I’m not sure which one because i installed those two at the same time. After I installed those plugins, I don’t have to use” ctr +alt+ R” anymore. I just type “rafce” directly from then

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Год назад

      Yes, I fixed mine awhile back. It was a setting in VS Code that had been altered.

  • @testororo6091
    @testororo6091 2 года назад

    THX! Make more advanced content please

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      You're welcome! I just completed a Redux Toolkit series that is advanced 💯

  • @wiseacreserj
    @wiseacreserj 2 года назад

    Thank you sir. Tell me please, what font (in editor) you use in this video?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      You're welcome! I am using the Github Theme extension for VS Code. It has several options. I choose the "Dark Default".

    • @wiseacreserj
      @wiseacreserj 2 года назад

      @@DaveGrayTeachesCode Thanks, but can you copy what you have in Settings -> Editor:Font Family

  • @jeremyko1765
    @jeremyko1765 2 года назад +2

    js framework : a self-destructive ecosystem.

  • @julian.castro18
    @julian.castro18 11 месяцев назад

    Would it be a better pratice to use instead of since this route is nested inside a ? I tried making that change and it routes just fine. Thank you very much.

  • @ahmedsirag2618
    @ahmedsirag2618 7 месяцев назад

    Nice Video by the way it's not _rface remove the underscore and it will work for you

  • @PavithranLion
    @PavithranLion Год назад

    sir plz do state management in react & Context API useContext in this version ...axios and custom hook worked well ,,but state management little bit confusion

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Год назад

      I am using the Context API in my recent React form tutorials: ruclips.net/video/FGM6FQmdX8I/видео.html

  • @odukoyasheriff9735
    @odukoyasheriff9735 9 месяцев назад

    Hello Dave gray, have been stuck in this tutorial video even after watching the new version
    example of problem
    import { useParams } from "react-router-dom";
    const PostPage = ({ posts, handleDelete }) => {
    const { id } = useParams();
    const post = posts.find(post => (post.id).toString() === id)
    return(


    {post &&

    {post.title}
    {post.datetime}
    {post.body}
    handleDelete(post.id)}>Delete

    }
    {!post &&
    No post available
    }

    after coding the home post it work, function and display but i code this in postpage it's not displaying or function and I don't know the reason why it happen such way, and its delay me to process on the class. sir can you help solve the problem, thanks for the tutorial class.

  • @waleedreaper
    @waleedreaper 10 месяцев назад

    You don't need to wrap a Route component inside other Route components. You can simply do this:

  • @IconicProps
    @IconicProps 2 года назад

    Mine works with no underscore, just rafce, and intellisense pops the completion with tab.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      I finally looked into this and had to make a couple of changes in my VS Code settings. Now mine works this way, too.

  • @samuelsolomon348
    @samuelsolomon348 Год назад +1

    i know this might be an inconvenience to you, but trying to keep up with this and the original chapter 16 17 18, is incredibly confusing so could you redo those videos with the V6 React Router

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Год назад +1

      I will create a new React course at some point, but technology keeps moving forward. I cannot edit and update videos once they are published to RUclips. My redo will be to publish a new course eventually. Thanks!

    • @samuelsolomon348
      @samuelsolomon348 Год назад

      @@DaveGrayTeachesCode thank you, i think i jumped the gun when commenting, i just gave it a go and i understood it, so i just want to say thank you again for the update

    • @KurgerBurger
      @KurgerBurger Год назад

      @@DaveGrayTeachesCode Perhaps just a redo of Chapters 16 & 17. Lot's of work I know.

  • @narenderkonka9001
    @narenderkonka9001 Год назад

    why we need use strict mode ?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Год назад

      Strict mode can be very helpful when you are developing your app.

  • @viktorwhitte7549
    @viktorwhitte7549 6 месяцев назад

    Pls can you work on the Edit post as well

  • @azamdan1607
    @azamdan1607 Год назад

    React router updated to 6.12. is there any code change?

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Год назад +1

      Possibly. I need to do another update on where RR is now. You can always install the version I am using here - listed in my package.json file.

  • @devmesa8398
    @devmesa8398 10 месяцев назад

    8:20 For me, it's just `rafce` without the underscore.

  • @abdulrahmanagboolaosho3582
    @abdulrahmanagboolaosho3582 Год назад

    when typing it into the document you don't need to add the underscore (rafce not _ rafce)

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Год назад +1

      Correct. I had something in VS Code settings I needed to correct. All good now.

  • @tusharshelke6444
    @tusharshelke6444 Год назад

    what themes is this?

  • @DeepakGupta-hj2dv
    @DeepakGupta-hj2dv 2 года назад

    Can you make a video on redux thunk and redux saga separate video

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      Yes, I would like to do these!

    • @DeepakGupta-hj2dv
      @DeepakGupta-hj2dv 2 года назад

      @@DaveGrayTeachesCode please next video same topic like redux thunk and saga

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      @@DeepakGupta-hj2dv It won't be the next video because I already have a schedule but I am adding these to the list 💯

    • @DeepakGupta-hj2dv
      @DeepakGupta-hj2dv 2 года назад

      Okk

  • @colourinblack
    @colourinblack 2 года назад

    Hey Dave. Just type rafce Not the underscore _rafce

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад +1

      There is a difference. Leaving out the underscore also includes the React import at the top of the file which is no longer needed. Otherwise, they are the same. 💯

    • @colourinblack
      @colourinblack 2 года назад

      @@DaveGrayTeachesCode Ah nice. That's a good tip. Thank you.

  • @sdsd-ec8rw
    @sdsd-ec8rw 7 месяцев назад

    redundant in index.js You could have just put instead

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 месяцев назад

      No. You don't understand how this allows nested routes to match. The /* is important here.

    • @sdsd-ec8rw
      @sdsd-ec8rw 7 месяцев назад

      @@DaveGrayTeachesCode do you have a link to documentation? Works perfectly fine without this piece of code.

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  7 месяцев назад

      It will work for specified routes but it won't match others. You should match others with the "splat" aka wildcard which is an asterisk. Docs: reactrouter.com/en/main/route/route#splats
      I cover it here: ruclips.net/video/XBRLVRjZ3CQ/видео.htmlsi=mQcCunWffxo4Fmg5&t=316 ..now that said, I have provided a lot of good information in this video and on my channel. Yet, on more than one video now, you have commented in a negative way like you are looking for anywhere I may not be perfect no matter how helpful the rest of the video is. Let me save you some time.. I'm not perfect. My advice to you.. stay positive and be polite. It will help you in the long run.

  • @WrathNBrimstone
    @WrathNBrimstone 2 года назад

    React Dom no longer renders must use createRoot , needs updated once again

  • @kishalayray7570
    @kishalayray7570 Год назад

    Only rafce

  • @sportshome6504
    @sportshome6504 Год назад

    React router updated it to v6.4

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  Год назад +1

      Yes they did some new features. I will cover it. That said, not breaking changes or the version would move to 7.

    • @sportshome6504
      @sportshome6504 Год назад

      @@DaveGrayTeachesCode Thank You

  • @WrathNBrimstone
    @WrathNBrimstone 2 года назад

    teaching how to update an applicaiton from previous code is a good exercise, but you can't create the previous version project tutorial to learn the concepts to understand what you're updating here so its a catch 22

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      There is a link to the starter code in the description. This is an update to the React Router tutorial in my full React course, and it has helped many. I hope you are doing well my friend. Your comments are somewhat negative overall. Please have a good day.

  • @salihhasan9662
    @salihhasan9662 2 года назад

    don't write _rafce write that rafce and Enter

    • @DaveGrayTeachesCode
      @DaveGrayTeachesCode  2 года назад

      I discovered my IntelliSense settings were off in VS code at the time. It all works as it should now.

  • @mohamedyoussef8835
    @mohamedyoussef8835 2 года назад

    Awesome Tutorial +++++++++++++++++++++ Thank You

  • @mohamedyoussef8835
    @mohamedyoussef8835 2 года назад

    Awesome Tutorial +++++++++++++++++++++ Thank You