React Router v6 Upgrade Guide - Refactoring from v5

Поділитися
Вставка
  • Опубліковано 5 жов 2024

КОМЕНТАРІ • 25

  • @cu48
    @cu48 2 роки тому +1

    Thanks for your video. I wonder that things.

  • @fh3r3
    @fh3r3 2 роки тому

    Awesome, thanks Mario Mirror

  • @mohamedsabriee
    @mohamedsabriee 2 роки тому

    I like your explanation 💚

  • @user-dysekh
    @user-dysekh 2 роки тому

    Thank you.

  • @ДаниилСоболев-ц6п
    @ДаниилСоболев-ц6п 2 роки тому

    Updates are minor. Only useNavigation looks useful, but anyway that behavior is simple to code by yourself.

    • @mariusespejo
      @mariusespejo  2 роки тому

      not really something worth coding yourself, that's why these libraries exist so you don't have to reinvent

  • @nanonkay5669
    @nanonkay5669 2 роки тому +1

    Sometimes I wonder why you would wanna use an extra library instead of just using next js??

    •  2 роки тому

      Because Next.js is opinionated on a number of topics, while an ejected CRA gives you full control of your application.

    • @mariusespejo
      @mariusespejo  2 роки тому +2

      You’re comparing apples to oranges. Next is great, but it’s an entire framework, it solves for much more than just routing. If it fits your use case go for it.

  • @anubaby7636
    @anubaby7636 2 роки тому

    what can I use in the place of usenavigate in case of class components?

    • @mariusespejo
      @mariusespejo  2 роки тому

      I highly recommend just switching over to function components to utilize hooks, but if you really can’t then you can make a simple HOC which utilizes those hooks and you can use it wrap your class components (providing navigate via props), something like this: stackoverflow.com/questions/63786452/react-navigate-router-v6-invalid-hook-call

  • @oscar5915
    @oscar5915 2 роки тому

    Sir can i ask how to redirect to 404 page if the link is invalid using rrd v6? your reply is highly appreciated

    • @mariusespejo
      @mariusespejo  2 роки тому

      Pretty much just provide a route with path “*” and that will match any other route that isn’t already matched by other routes. Then just give it an element/component that is your 404 page

    • @oscar5915
      @oscar5915 2 роки тому

      @@mariusespejo
      i wrote it like this but it seems didn't works, any ideas sir?

    • @mariusespejo
      @mariusespejo  2 роки тому +1

      That’s pretty much it but obviously you wouldn’t have just that one route, and it likely should be defined at the topmost Routes that you have. Make sure to review docs: reactrouter.com/docs/en/v6/getting-started/overview#not-found-routes

    • @oscar5915
      @oscar5915 2 роки тому

      @@mariusespejo omg it works thank a lot... subscribed to your channel

    • @mariusespejo
      @mariusespejo  2 роки тому +1

      Great! Glad you got it working, and thank you!

  • @VovanSuper
    @VovanSuper 2 роки тому

    ... OK , v6 becomes a bit like Angular's router :)