Skip to content

Commit 23fccd1

Browse files
authored
docs: Add useMatch section in upgrade docs (#8280)
1 parent bda3295 commit 23fccd1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/upgrading/v5.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,20 @@ import { StaticRouter } from "react-router-dom/server";
855855

856856
This change was made both to follow more closely the convention established by the `react-dom` package and to help users understand better what a `<StaticRouter>` is for and when it should be used (on the server).
857857

858+
## Replace `useRouteMatch` with `useMatch`
859+
860+
`useMatch` is very similar to v5's `useRouteMatch`, with a few key differences:
861+
862+
- It uses our new [path pattern matching algorithm](#note-on-route-path-patterns)
863+
- The pattern argument is now required
864+
- No longer accepts an array of patterns
865+
- When passing a pattern as an object, some of the options have been renamed to better align with other APIs in v6
866+
- `useRouteMatch({ strict })` is now `useMatch({ end })`
867+
- `useRouteMatch({ sensitive })` is now `useMatch({ caseSensitive })`
868+
- It returns a match object with a different shape
869+
870+
To see the exact API of the new `useMatch` hook and its type declaration, check out our [API Reference](../api.md#usematch). <!-- TODO: Show examples for refactoring useRouteMatch -->
871+
858872
## What did we miss?
859873

860874
Despite our best attempts at being thorough, it's very likely that we missed something. If you follow this upgrade guide and find that to be the case, please let us know. We are happy to help you figure out what to do with your v5 code to be able to upgrade and take advantage of all of the cool stuff in v6.

0 commit comments

Comments
 (0)