From b12a220bb7cb9c9f6004133a937ecce60040213f Mon Sep 17 00:00:00 2001 From: "michal.antczak" Date: Mon, 23 May 2022 17:00:22 +0200 Subject: [PATCH 1/2] Add info about changes in matchPath() to upgrading v5 guide --- docs/upgrading/v5.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/docs/upgrading/v5.md b/docs/upgrading/v5.md index 42dff00bbe..526db63459 100644 --- a/docs/upgrading/v5.md +++ b/docs/upgrading/v5.md @@ -891,6 +891,41 @@ To see the exact API of the new `useMatch` hook and its type declaration, check +## 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"); +``` + + + ## `` is not currently supported `` 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. From 81393e1d7255d960e613fd4634fa08b47f32a7f8 Mon Sep 17 00:00:00 2001 From: "michal.antczak" Date: Mon, 23 May 2022 17:14:52 +0200 Subject: [PATCH 2/2] Add signature --- contributors.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.yml b/contributors.yml index c121988cd2..b33ad829ae 100644 --- a/contributors.yml +++ b/contributors.yml @@ -61,3 +61,4 @@ - underager - vijaypushkin - vikingviolinist +- michal-antczak