Skip to content

Commit

Permalink
docs: Add info about changes in matchPath() to upgrading/v5 guide (#8894
Browse files Browse the repository at this point in the history
)

* Add info about changes in matchPath() to upgrading v5 guide

* Add signature
  • Loading branch information
michal-antczak committed May 24, 2022
1 parent 110b924 commit 78c643e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions contributors.yml
Expand Up @@ -61,3 +61,4 @@
- underager
- vijaypushkin
- vikingviolinist
- michal-antczak
35 changes: 35 additions & 0 deletions docs/upgrading/v5.md
Expand Up @@ -891,6 +891,41 @@ To see the exact API of the new `useMatch` hook and its type declaration, check

<!-- TODO: Show examples for refactoring useRouteMatch -->

## Change the order of arguments passed to `matchPath`. Change pathPattern options.

Since version 6 the order of arguments passed to `matchPath` function has changed. Also pattern options has changed.

- first argument is pathPattern object, then comes pathname
- pathPattern doesn't include `exact` and `strict` options any more. New `caseSensitive` and `end` options has been added.

Please refactor it as follows:

Before:
```js
// This is a React Router v5 app
import { matchPath } from "react-router-dom";

const match = matchPath("/users/123", {
path: "/users/:id",
exact: true, // Optional, defaults to false
strict: false // Optional, defaults to false
});
```

After:
```js
// This is a React Router v6 app
import { matchPath } from "react-router-dom";

const match = matchPath({
path: "/users/:id",
caseSensitive: false, // Optional. Should be `true` if the static portions of the `path` should be matched in the same case.
end: true // Optional. Should be `true` if this pattern should match the entire URL pathname
}, "/users/123");
```



## `<Prompt>` is not currently supported

`<Prompt>` from v5 (along with `usePrompt` and `useBlocker` from the v6 betas) are not included in the current released version of v6. We decided we'd rather ship with what we have than take even more time to nail down a feature that isn't fully baked. We will absolutely be working on adding this back in to v6 at some point in the near future, but not for our first stable release of 6.x.
Expand Down

0 comments on commit 78c643e

Please sign in to comment.