react-router v6.0.0-alpha.4 Release Notes

Release Date: 2020-05-05 // almost 4 years ago
  • ๐Ÿš€ Lots of great stuff in this release, especially if you like Intellisense :)

    Major Features

    • Migrated the core codebase to TypeScript and added TypeScript declarations
    • โž• Added a migration guide for folks coming from reach/router
    • โž• Added useInRouterContext hook for determining if you're in the context of a router or not
    • โž• Added useLocationPending hook (experimental)
    • โž• Added matchPath function for manually matching paths to URL pathnames

    ๐Ÿš€ Note: experimental features rely on an experimental release of React and will probably be moved into a separate "experimental" release channel in the near future.

    Major Changes

    ๐Ÿš€ Warning: This release breaks compatibility with 6.0.0-alpha.3

    • โšก๏ธ useSearchParams now returns [searchParams, setSearchParams] (similar to useState). setSearchParams is a wrapper for navigate that updates the query string on the current URL. See the updated guide on working with the query string.
    • โœ‚ Removed the <StaticRouter context> API. We don't support navigation on the initial render in v6, so this API is unnecessary.
    • useMatch takes a route path (instead of a link to value as it did previously). It should have always taken a route path; this was just a simple oversight.

    ๐Ÿ›  Bugfixes

    • ๐Ÿ›  Fixed a bug with multiple nested * routes
    • ๐Ÿ’ป Force stable sort in browsers that don't have it so routes that otherwise rank equally maintain the order in which they were originally defined

    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@next react-router-dom@next
    

    Or, if you're on React Native:

    $ yarn add react-router@next react-router-native@next
    

    ๐Ÿ“š 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!