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: packages/react-router-dom-v5-compat/README.md
+22-16Lines changed: 22 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -256,40 +256,46 @@ BAM 💥 This entire branch of your UI is migrated to v6!
256
256
257
257
Once your deepest `Switch` components are converted, go up to their parent `<Switch>` and repeat the process. Keep doing this all the way up the tree until all components are migrated to v6 APIs.
258
258
259
-
If you have `<Routes>`rendered deeper in the tree of a `<Route>`, you'll need to use a **splat path** so that those deeper URLs continue to match.
259
+
When you convert a `<Switch>` to `<Routes>`that has descendant `<Routes>`deeper in its tree, there are a couple things you need to do in both places for everything to continue matching correctly.
260
260
261
261
👉️ Add splat paths to any `<Route>` with a **descendant**`<Routes>`
This ensures deeper URLs like `/projects/123` continue to match that route. Note that this isn't needed if the route doesn't have any descendant `<Routes>`.
275
275
276
-
// This one was already migrated earlier but it won't match anymore
277
-
// if you don't add the "*" when you change <Switch> to <Routes>
278
-
function Descendant() {
276
+
👉 Convert route paths from absolute to relative paths
The splat is only needed for routes with **descendant routes** in their tree.
298
+
Usually descendant Switch (and now Routes) were using the ancestor `match.path` to build their entire path. When the ancestor Switch is converted to `<Routes>` you no longer need to do this this manually, it happens automatically. Also, if you don't change them to relative paths, they will no longer match, so you need to do this step.
0 commit comments