You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/upgrading/v5.md
+35Lines changed: 35 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -891,6 +891,41 @@ To see the exact API of the new `useMatch` hook and its type declaration, check
891
891
892
892
<!-- TODO: Show examples for refactoring useRouteMatch -->
893
893
894
+
## Change the order of arguments passed to `matchPath`. Change pathPattern options.
895
+
896
+
Since version 6 the order of arguments passed to `matchPath` function has changed. Also pattern options has changed.
897
+
898
+
- first argument is pathPattern object, then comes pathname
899
+
- pathPattern doesn't include `exact` and `strict` options any more. New `caseSensitive` and `end` options has been added.
900
+
901
+
Please refactor it as follows:
902
+
903
+
Before:
904
+
```js
905
+
// This is a React Router v5 app
906
+
import { matchPath } from"react-router-dom";
907
+
908
+
constmatch=matchPath("/users/123", {
909
+
path:"/users/:id",
910
+
exact:true, // Optional, defaults to false
911
+
strict:false// Optional, defaults to false
912
+
});
913
+
```
914
+
915
+
After:
916
+
```js
917
+
// This is a React Router v6 app
918
+
import { matchPath } from"react-router-dom";
919
+
920
+
constmatch=matchPath({
921
+
path:"/users/:id",
922
+
caseSensitive:false, // Optional. Should be `true` if the static portions of the `path` should be matched in the same case.
923
+
end:true// Optional. Should be `true` if this pattern should match the entire URL pathname
924
+
}, "/users/123");
925
+
```
926
+
927
+
928
+
894
929
## `<Prompt>` is not currently supported
895
930
896
931
`<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.
0 commit comments