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.
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
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
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
Thanks for your video. I wonder that things.
Awesome, thanks Mario Mirror
😂
I like your explanation 💚
Thanks!
Thank you.
Updates are minor. Only useNavigation looks useful, but anyway that behavior is simple to code by yourself.
not really something worth coding yourself, that's why these libraries exist so you don't have to reinvent
Sometimes I wonder why you would wanna use an extra library instead of just using next js??
Because Next.js is opinionated on a number of topics, while an ejected CRA gives you full control of your application.
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.
what can I use in the place of usenavigate in case of class components?
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
Sir can i ask how to redirect to 404 page if the link is invalid using rrd v6? your reply is highly appreciated
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
@@mariusespejo
i wrote it like this but it seems didn't works, any ideas sir?
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
@@mariusespejo omg it works thank a lot... subscribed to your channel
Great! Glad you got it working, and thank you!
... OK , v6 becomes a bit like Angular's router :)