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
+13-10Lines changed: 13 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -893,39 +893,42 @@ To see the exact API of the new `useMatch` hook and its type declaration, check
893
893
894
894
## Change the order of arguments passed to `matchPath`. Change pathPattern options.
895
895
896
-
Since version 6 the order of arguments passed to `matchPath` function has changed. Also pattern options has changed.
896
+
Since version 6 the order of arguments passed to `matchPath` function has changed. Also pattern options has changed.
897
897
898
898
- first argument is pathPattern object, then comes pathname
899
899
- pathPattern doesn't include `exact` and `strict` options any more. New `caseSensitive` and `end` options has been added.
900
900
901
901
Please refactor it as follows:
902
902
903
903
Before:
904
+
904
905
```js
905
906
// This is a React Router v5 app
906
907
import { matchPath } from"react-router-dom";
907
908
908
909
constmatch=matchPath("/users/123", {
909
910
path:"/users/:id",
910
-
exact:true, // Optional, defaults to false
911
-
strict:false// Optional, defaults to false
911
+
exact:true, // Optional, defaults to false
912
+
strict:false,// Optional, defaults to false
912
913
});
913
914
```
914
915
915
916
After:
917
+
916
918
```js
917
919
// This is a React Router v6 app
918
920
import { matchPath } from"react-router-dom";
919
921
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");
922
+
constmatch=matchPath(
923
+
{
924
+
path:"/users/:id",
925
+
caseSensitive:false, // Optional. Should be `true` if the static portions of the `path` should be matched in the same case.
926
+
end:true, // Optional. Should be `true` if this pattern should match the entire URL pathname
927
+
},
928
+
"/users/123"
929
+
);
925
930
```
926
931
927
-
928
-
929
932
## `<Prompt>` is not currently supported
930
933
931
934
`<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