I have not been so burned from the decision to update the dependencies of the project for a long time and it was react router
As with version 3, the developers decided that since the major, without a code mod, you can break everything and not leave backward compatibility
After the update, the familiar codebase is highlighted in red (typescript)
useHistory is completely cut out, now we need to use a lot of different hooks.
If you have class components, then you should either pass through props or create a custom hook where these hooks will be called
history.replace now navigate(url, {replace: true})
histore.goBack now navigate(-1)
state was removed from prop to now it is a separate prop on Link
useLocation cannot be typified, in order to pass typing for state through <> now only typecasts
oh, I naively thought that the useSearchParams hook signature would make it possible to conveniently work with parameters, but when I opened the example, I didn’t understand anything at all
I burn, I have stress and hatred. For me, react-router is dead and is now the worst react library ever. I feel the same way about the remix team.
Please developers, don't upgrade and don't use react router in your projects.
No more of this pain. Don't use it to instantly turn your routing into a pumpkin
Top comments (2)
Looks like you completely missed the guide for upgrading. Agree that breaking changes sucks but bashing libraries for no good reason just because you couldn't do somehting that's perfectly doable is not the route either. Hope you can make things work by reading the guide: reactrouter.com/docs/en/v6/upgradi...
I read the guide and did the migration according to it. It’s just that the project is now about money and they don’t care about the ecosystem and the community. They make a remix and try to make money from it.