Skip to content

Commit b8a8daf

Browse files
committed
update change file and docs
Assisted-By: devx/aad5d142-46d9-4330-a723-1b17588b7654
1 parent 9331b06 commit b8a8daf

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

docs/upgrading/future.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ The flag is also available with `createHashRouter` and `createMemoryRouter`.
133133

134134
**Update your Code**
135135

136-
No route configuration changes are required, but you should review any routes with overlapping patterns to ensure the new ranking behavior selects the intended route.
136+
No route configuration changes are required, but you should review any routes with overlapping patterns to ensure the new ranking behavior selects the intended route. This is mostly expected to be an issue when you have deep dynamic param paths which could result in an aggregate score that outweighs a shallower static segment route.
137137

138138
For example, both of these routes match `/products/one/two/three`:
139139

@@ -142,14 +142,14 @@ const routes = [
142142
{ path: "/products/*", id: "products" },
143143
{
144144
path: "/:first/:second/:third/:fourth",
145-
id: "four-segments",
145+
id: "segments",
146146
},
147147
];
148148
```
149149

150-
The legacy matcher selects `four-segments` based on its aggregate segment score. The new matcher selects `products` because its static `products` segment is more specific than the dynamic `:first` segment in the same position.
150+
The legacy matcher selects `segments` based on its aggregate segment score. The new matcher selects `products` because its static `products` segment is more specific than the dynamic `:first` segment in the same position.
151151

152-
Once you enable this flag, use `router.match()` when you need to match a location. Standalone matching APIs such as `matchRoutes`, `matchPath`, and `useMatch` continue to use the legacy matcher and may return different matches than the router.
152+
Once you enable this flag, use the `router.match()` when you need to match a location (this is currently marked private and will become stable at the same time this flag stabilizes). Standalone matching APIs such as `matchRoutes`, `matchPath`, and `useMatch` continue to use the legacy matcher and may return different matches than the router.
153153

154154
Case-sensitive routes are not currently supported with this flag.
155155

packages/react-router/.changes/unstable.route-pattern-matching.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
Add a Data Mode-only POC for route-pattern based route matching
1+
Add a new Data Mode-only `future.unstable_routePatternMatching` flag to opt into more efficient `@remix-run/route-pattern` based route matching internally
22

3-
- Adds `future.unstable_routePatternMatching: true` for Data Router matching only
4-
- Uses `@remix-run/route-pattern` internally to match and rank route branches when the flag is enabled
5-
- Keeps route definitions and public route/match fields in React Router path syntax
6-
- Manual matching APIs such as `matchRoutes`, `matchPath`, and `useMatch` continue to use legacy path matching and should not be used once a Data Router opts into `future.unstable_routePatternMatching` because they may not return the same matches as the router
3+
- No code changes required - syntax remains the same for pubic route definitions and route match fields
4+
- Once opting into this flag, you should no longer user legacy matching APIs (`matchRoutes`/`matchPath`/`useMatch`) as they are hardcoded to the previous regex-based matcher
5+
- A new `router.match()` API exists for those use cases but it's marked private and considered unstable along with the flag
76
- Path generation APIs such as `generatePath` and `href` continue to accept React Router path syntax
8-
- Adds an `unstable_validateParams` POC using keyed regular expressions so a route can reject matched params and let matching continue. Params omitted from a match, such as optional params, are not validated.
7+
- This flag also comes with a new `unstable_validateParams` route field which uses keyed regular expressions so a route can reject matched params and let matching continue (non-matched optional params are not validated)
98

109
```ts
1110
let router = createBrowserRouter(

0 commit comments

Comments
 (0)