react-router v6.0.0-alpha.3 Release Notes
Release Date: 2020-04-04 // almost 4 years ago-
Major Features
- โ Added a new
useSearchParams
hook (see f59ee54)
๐ The
useSearchParams
hook returns aURLSearchParams
object created from the currentlocation.search
string. This is a feature that people have wanted for a while, but we were always hesitant to ship a full-blown query parser with the router. Well, now that we haveURLSearchParams
widely available, we don't have to. I wrote up a small guide about how to useuseSearchParams
if you'd like to read more.Major Changes
๐ Warning: This release breaks compatibility with 6.0.0-alpha.2
- ๐
Redirect
(andredirectTo
inuseRoutes
) was removed (see cbcd398) - ๐ We no longer support redirecting on the initial render, due to compatibility issues with future versions of React
โก๏ธ React won't let us change the state in an ancestor component on the initial render w/out warning, so we had to remove the
<Redirect>
component, as well as the ability to do anavigate()
on the initial render. You can still render a<Navigate>
, but it won't actually update the page until the next render.๐ป If you really need to redirect on the initial render, you can either a) do it on your server (probably best, so it can be cached at the HTTP level instead of doing it in every user's browser) or b) do it outside of React Router (e.g. using the history API directly).
Installing
Development for v6 is happening on the
dev
branch.โ If you'd like to test it out, install from npm:
$ npm install react-router@6 react-router-dom@6
Or, if you're on React Native:
$ yarn add react-router@6 react-router-native@6
๐ We are actively working on documentation. For now, if you're just interested in testing things out you may be interested in the getting started guide. If you're interested in upgrading an existing app, please check out the v5 to v6 migration guide.
Enjoy!
- โ Added a new