UNPKG

29.3 kB Markdown View Raw
1 # `react-router`
2
3 ## 6.23.0
4
5 ### Minor Changes
6
7 - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098))
8 - This option allows Data Router applications to take control over the approach for executing route loaders and actions
9 - The default implementation is today's behavior, to fetch all loaders in parallel, but this option allows users to implement more advanced data flows including Remix single-fetch, middleware/context APIs, automatic loader caching, and more
10
11 ### Patch Changes
12
13 - Updated dependencies:
14 - `@remix-run/router@1.16.0`
15
16 ## 6.22.3
17
18 ### Patch Changes
19
20 - Updated dependencies:
21 - `@remix-run/router@1.15.3`
22
23 ## 6.22.2
24
25 ### Patch Changes
26
27 - Updated dependencies:
28 - `@remix-run/router@1.15.2`
29
30 ## 6.22.1
31
32 ### Patch Changes
33
34 - Fix encoding/decoding issues with pre-encoded dynamic parameter values ([#11199](https://github.com/remix-run/react-router/pull/11199))
35 - Updated dependencies:
36 - `@remix-run/router@1.15.1`
37
38 ## 6.22.0
39
40 ### Patch Changes
41
42 - Updated dependencies:
43 - `@remix-run/router@1.15.0`
44
45 ## 6.21.3
46
47 ### Patch Changes
48
49 - Remove leftover `unstable_` prefix from `Blocker`/`BlockerFunction` types ([#11187](https://github.com/remix-run/react-router/pull/11187))
50
51 ## 6.21.2
52
53 ### Patch Changes
54
55 - Updated dependencies:
56 - `@remix-run/router@1.14.2`
57
58 ## 6.21.1
59
60 ### Patch Changes
61
62 - Fix bug with `route.lazy` not working correctly on initial SPA load when `v7_partialHydration` is specified ([#11121](https://github.com/remix-run/react-router/pull/11121))
63 - Updated dependencies:
64 - `@remix-run/router@1.14.1`
65
66 ## 6.21.0
67
68 ### Minor Changes
69
70 - Add a new `future.v7_relativeSplatPath` flag to implement a breaking bug fix to relative routing when inside a splat route. ([#11087](https://github.com/remix-run/react-router/pull/11087))
71
72 This fix was originally added in [#10983](https://github.com/remix-run/react-router/issues/10983) and was later reverted in [#11078](https://github.com/remix-run/react-router/pull/11078) because it was determined that a large number of existing applications were relying on the buggy behavior (see [#11052](https://github.com/remix-run/react-router/issues/11052))
73
74 **The Bug**
75 The buggy behavior is that without this flag, the default behavior when resolving relative paths is to _ignore_ any splat (`*`) portion of the current route path.
76
77 **The Background**
78 This decision was originally made thinking that it would make the concept of nested different sections of your apps in `<Routes>` easier if relative routing would _replace_ the current splat:
79
80 ```jsx
81
82 <Routes>
83 <Route path="/" element={<Home />} />
84 <Route path="dashboard/*" element={<Dashboard />} />
85 </Routes>
86
87 ```
88
89 Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
90
91 ```jsx
92 function Dashboard() {
93 return (
94 <div>
95 <h2>Dashboard</h2>
96 <nav>
97 <Link to="/">Dashboard Home</Link>
98 <Link to="team">Team</Link>
99 <Link to="projects">Projects</Link>
100 </nav>
101
102 <Routes>
103 <Route path="/" element={<DashboardHome />} />
104 <Route path="team" element={<DashboardTeam />} />
105 <Route path="projects" element={<DashboardProjects />} />
106 </Routes>
107 </div>
108 );
109 }
110 ```
111
112 Now, all links and route paths are relative to the router above them. This makes code splitting and compartmentalizing your app really easy. You could render the `Dashboard` as its own independent app, or embed it into your large app without making any changes to it.
113
114 **The Problem**
115
116 The problem is that this concept of ignoring part of a path breaks a lot of other assumptions in React Router - namely that `"."` always means the current location pathname for that route. When we ignore the splat portion, we start getting invalid paths when using `"."`:
117
118 ```jsx
119 // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
120 function DashboardTeam() {
121 // ❌ This is broken and results in <a href="/dashboard">
122 return <Link to=".">A broken link to the Current URL</Link>;
123
124 // ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
125 return <Link to="./team">A broken link to the Current URL</Link>;
126 }
127 ```
128
129 We've also introduced an issue that we can no longer move our `DashboardTeam` component around our route hierarchy easily - since it behaves differently if we're underneath a non-splat route, such as `/dashboard/:widget`. Now, our `"."` links will, properly point to ourself _inclusive of the dynamic param value_ so behavior will break from it's corresponding usage in a `/dashboard/*` route.
130
131 Even worse, consider a nested splat route configuration:
132
133 ```jsx
134
135 <Routes>
136 <Route path="dashboard">
137 <Route path="*" element={<Dashboard />} />
138 </Route>
139 </Routes>
140
141 ```
142
143 Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
144
145 Another common issue arose in Data Routers (and Remix) where any `<Form>` should post to it's own route `action` if you the user doesn't specify a form action:
146
147 ```jsx
148 let router = createBrowserRouter({
149 path: "/dashboard",
150 children: [
151 {
152 path: "*",
153 action: dashboardAction,
154 Component() {
155 // ❌ This form is broken! It throws a 405 error when it submits because
156 // it tries to submit to /dashboard (without the splat value) and the parent
157 // `/dashboard` route doesn't have an action
158 return <Form method="post">...</Form>;
159 },
160 },
161 ],
162 });
163 ```
164
165 This is just a compounded issue from the above because the default location for a `Form` to submit to is itself (`"."`) - and if we ignore the splat portion, that now resolves to the parent route.
166
167 **The Solution**
168 If you are leveraging this behavior, it's recommended to enable the future flag, move your splat to it's own route, and leverage `../` for any links to "sibling" pages:
169
170 ```jsx
171
172 <Routes>
173 <Route path="dashboard">
174 <Route index path="*" element={<Dashboard />} />
175 </Route>
176 </Routes>
177
178
179 function Dashboard() {
180 return (
181 <div>
182 <h2>Dashboard</h2>
183 <nav>
184 <Link to="..">Dashboard Home</Link>
185 <Link to="../team">Team</Link>
186 <Link to="../projects">Projects</Link>
187 </nav>
188
189 <Routes>
190 <Route path="/" element={<DashboardHome />} />
191 <Route path="team" element={<DashboardTeam />} />
192 <Route path="projects" element={<DashboardProjects />} />
193 </Router>
194 </div>
195 );
196 }
197 ```
198
199 This way, `.` means "the full current pathname for my route" in all cases (including static, dynamic, and splat routes) and `..` always means "my parents pathname".
200
201 ### Patch Changes
202
203 - Properly handle falsy error values in ErrorBoundary's ([#11071](https://github.com/remix-run/react-router/pull/11071))
204 - Updated dependencies:
205 - `@remix-run/router@1.14.0`
206
207 ## 6.20.1
208
209 ### Patch Changes
210
211 - Revert the `useResolvedPath` fix for splat routes due to a large number of applications that were relying on the buggy behavior (see ). We plan to re-introduce this fix behind a future flag in the next minor version. ([#11078](https://github.com/remix-run/react-router/pull/11078))
212 - Updated dependencies:
213 - `@remix-run/router@1.13.1`
214
215 ## 6.20.0
216
217 ### Minor Changes
218
219 - Export the `PathParam` type from the public API ([#10719](https://github.com/remix-run/react-router/pull/10719))
220
221 ### Patch Changes
222
223 - Fix bug with `resolveTo` in splat routes ([#11045](https://github.com/remix-run/react-router/pull/11045))
224 - This is a follow up to [#10983](https://github.com/remix-run/react-router/pull/10983) to handle the few other code paths using `getPathContributingMatches`
225 - This removes the `UNSAFE_getPathContributingMatches` export from `@remix-run/router` since we no longer need this in the `react-router`/`react-router-dom` layers
226 - Updated dependencies:
227 - `@remix-run/router@1.13.0`
228
229 ## 6.19.0
230
231 ### Minor Changes
232
233 - Add `unstable_flushSync` option to `useNavigate`/`useSumbit`/`fetcher.load`/`fetcher.submit` to opt-out of `React.startTransition` and into `ReactDOM.flushSync` for state updates ([#11005](https://github.com/remix-run/react-router/pull/11005))
234 - Remove the `unstable_` prefix from the [`useBlocker`](https://reactrouter.com/en/main/hooks/use-blocker) hook as it's been in use for enough time that we are confident in the API. We do not plan to remove the prefix from `unstable_usePrompt` due to differences in how browsers handle `window.confirm` that prevent React Router from guaranteeing consistent/correct behavior. ([#10991](https://github.com/remix-run/react-router/pull/10991))
235
236 ### Patch Changes
237
238 - Fix `useActionData` so it returns proper contextual action data and not _any_ action data in the tree ([#11023](https://github.com/remix-run/react-router/pull/11023))
239
240 - Fix bug in `useResolvedPath` that would cause `useResolvedPath(".")` in a splat route to lose the splat portion of the URL path. ([#10983](https://github.com/remix-run/react-router/pull/10983))
241
242 - ⚠️ This fixes a quite long-standing bug specifically for `"."` paths inside a splat route which incorrectly dropped the splat portion of the URL. If you are relative routing via `"."` inside a splat route in your application you should double check that your logic is not relying on this buggy behavior and update accordingly.
243
244 - Updated dependencies:
245 - `@remix-run/router@1.12.0`
246
247 ## 6.18.0
248
249 ### Patch Changes
250
251 - Fix the `future` prop on `BrowserRouter`, `HashRouter` and `MemoryRouter` so that it accepts a `Partial<FutureConfig>` instead of requiring all flags to be included. ([#10962](https://github.com/remix-run/react-router/pull/10962))
252 - Updated dependencies:
253 - `@remix-run/router@1.11.0`
254
255 ## 6.17.0
256
257 ### Patch Changes
258
259 - Fix `RouterProvider` `future` prop type to be a `Partial<FutureConfig>` so that not all flags must be specified ([#10900](https://github.com/remix-run/react-router/pull/10900))
260 - Updated dependencies:
261 - `@remix-run/router@1.10.0`
262
263 ## 6.16.0
264
265 ### Minor Changes
266
267 - In order to move towards stricter TypeScript support in the future, we're aiming to replace current usages of `any` with `unknown` on exposed typings for user-provided data. To do this in Remix v2 without introducing breaking changes in React Router v6, we have added generics to a number of shared types. These continue to default to `any` in React Router and are overridden with `unknown` in Remix. In React Router v7 we plan to move these to `unknown` as a breaking change. ([#10843](https://github.com/remix-run/react-router/pull/10843))
268 - `Location` now accepts a generic for the `location.state` value
269 - `ActionFunctionArgs`/`ActionFunction`/`LoaderFunctionArgs`/`LoaderFunction` now accept a generic for the `context` parameter (only used in SSR usages via `createStaticHandler`)
270 - The return type of `useMatches` (now exported as `UIMatch`) accepts generics for `match.data` and `match.handle` - both of which were already set to `unknown`
271 - Move the `@private` class export `ErrorResponse` to an `UNSAFE_ErrorResponseImpl` export since it is an implementation detail and there should be no construction of `ErrorResponse` instances in userland. This frees us up to export a `type ErrorResponse` which correlates to an instance of the class via `InstanceType`. Userland code should only ever be using `ErrorResponse` as a type and should be type-narrowing via `isRouteErrorResponse`. ([#10811](https://github.com/remix-run/react-router/pull/10811))
272 - Export `ShouldRevalidateFunctionArgs` interface ([#10797](https://github.com/remix-run/react-router/pull/10797))
273 - Removed private/internal APIs only required for the Remix v1 backwards compatibility layer and no longer needed in Remix v2 (`_isFetchActionRedirect`, `_hasFetcherDoneAnything`) ([#10715](https://github.com/remix-run/react-router/pull/10715))
274
275 ### Patch Changes
276
277 - Updated dependencies:
278 - `@remix-run/router@1.9.0`
279
280 ## 6.15.0
281
282 ### Minor Changes
283
284 - Add's a new `redirectDocument()` function which allows users to specify that a redirect from a `loader`/`action` should trigger a document reload (via `window.location`) instead of attempting to navigate to the redirected location via React Router ([#10705](https://github.com/remix-run/react-router/pull/10705))
285
286 ### Patch Changes
287
288 - Ensure `useRevalidator` is referentially stable across re-renders if revalidations are not actively occurring ([#10707](https://github.com/remix-run/react-router/pull/10707))
289 - Updated dependencies:
290 - `@remix-run/router@1.8.0`
291
292 ## 6.14.2
293
294 ### Patch Changes
295
296 - Updated dependencies:
297 - `@remix-run/router@1.7.2`
298
299 ## 6.14.1
300
301 ### Patch Changes
302
303 - Fix loop in `unstable_useBlocker` when used with an unstable blocker function ([#10652](https://github.com/remix-run/react-router/pull/10652))
304 - Fix issues with reused blockers on subsequent navigations ([#10656](https://github.com/remix-run/react-router/pull/10656))
305 - Updated dependencies:
306 - `@remix-run/router@1.7.1`
307
308 ## 6.14.0
309
310 ### Patch Changes
311
312 - Strip `basename` from locations provided to `unstable_useBlocker` functions to match `useLocation` ([#10573](https://github.com/remix-run/react-router/pull/10573))
313 - Fix `generatePath` when passed a numeric `0` value parameter ([#10612](https://github.com/remix-run/react-router/pull/10612))
314 - Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573))
315 - Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622))
316 - Upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581))
317 - Updated dependencies:
318 - `@remix-run/router@1.7.0`
319
320 ## 6.13.0
321
322 ### Minor Changes
323
324 - Move [`React.startTransition`](https://react.dev/reference/react/startTransition) usage behind a [future flag](https://reactrouter.com/en/main/guides/api-development-strategy) to avoid issues with existing incompatible `Suspense` usages. We recommend folks adopting this flag to be better compatible with React concurrent mode, but if you run into issues you can continue without the use of `startTransition` until v7. Issues usually boils down to creating net-new promises during the render cycle, so if you run into issues you should either lift your promise creation out of the render cycle or put it behind a `useMemo`. ([#10596](https://github.com/remix-run/react-router/pull/10596))
325
326 Existing behavior will no longer include `React.startTransition`:
327
328 ```jsx
329
330 <Routes>{/*...*/}</Routes>
331
332
333
334 ```
335
336 If you wish to enable `React.startTransition`, pass the future flag to your component:
337
338 ```jsx
339
340 <Routes>{/*...*/}</Routes>
341
342
343
344 ```
345
346 ### Patch Changes
347
348 - Work around webpack/terser `React.startTransition` minification bug in production mode ([#10588](https://github.com/remix-run/react-router/pull/10588))
349
350 ## 6.12.1
351
352 > \[!WARNING]
353 > Please use version `6.13.0` or later instead of `6.12.1`. This version suffers from a `webpack`/`terser` minification issue resulting in invalid minified code in your resulting production bundles which can cause issues in your application. See [#10579](https://github.com/remix-run/react-router/issues/10579) for more details.
354
355 ### Patch Changes
356
357 - Adjust feature detection of `React.startTransition` to fix webpack + react 17 compilation error ([#10569](https://github.com/remix-run/react-router/pull/10569))
358
359 ## 6.12.0
360
361 ### Minor Changes
362
363 - Wrap internal router state updates with `React.startTransition` if it exists ([#10438](https://github.com/remix-run/react-router/pull/10438))
364
365 ### Patch Changes
366
367 - Updated dependencies:
368 - `@remix-run/router@1.6.3`
369
370 ## 6.11.2
371
372 ### Patch Changes
373
374 - Fix `basename` duplication in descendant `<Routes>` inside a `<RouterProvider>` ([#10492](https://github.com/remix-run/react-router/pull/10492))
375 - Updated dependencies:
376 - `@remix-run/router@1.6.2`
377
378 ## 6.11.1
379
380 ### Patch Changes
381
382 - Fix usage of `Component` API within descendant `<Routes>` ([#10434](https://github.com/remix-run/react-router/pull/10434))
383 - Fix bug when calling `useNavigate` from `<Routes>` inside a `<RouterProvider>` ([#10432](https://github.com/remix-run/react-router/pull/10432))
384 - Fix usage of `<Navigate>` in strict mode when using a data router ([#10435](https://github.com/remix-run/react-router/pull/10435))
385 - Updated dependencies:
386 - `@remix-run/router@1.6.1`
387
388 ## 6.11.0
389
390 ### Patch Changes
391
392 - Log loader/action errors to the console in dev for easier stack trace evaluation ([#10286](https://github.com/remix-run/react-router/pull/10286))
393 - Fix bug preventing rendering of descendant `<Routes>` when `RouterProvider` errors existed ([#10374](https://github.com/remix-run/react-router/pull/10374))
394 - Fix inadvertent re-renders when using `Component` instead of `element` on a route definition ([#10287](https://github.com/remix-run/react-router/pull/10287))
395 - Fix detection of `useNavigate` in the render cycle by setting the `activeRef` in a layout effect, allowing the `navigate` function to be passed to child components and called in a `useEffect` there. ([#10394](https://github.com/remix-run/react-router/pull/10394))
396 - Switched from `useSyncExternalStore` to `useState` for internal `@remix-run/router` router state syncing in `<RouterProvider>`. We found some [subtle bugs](https://codesandbox.io/s/use-sync-external-store-loop-9g7b81) where router state updates got propagated _before_ other normal `useState` updates, which could lead to footguns in `useEffect` calls. ([#10377](https://github.com/remix-run/react-router/pull/10377), [#10409](https://github.com/remix-run/react-router/pull/10409))
397 - Allow `useRevalidator()` to resolve a loader-driven error boundary scenario ([#10369](https://github.com/remix-run/react-router/pull/10369))
398 - Avoid unnecessary unsubscribe/resubscribes on router state changes ([#10409](https://github.com/remix-run/react-router/pull/10409))
399 - When using a `RouterProvider`, `useNavigate`/`useSubmit`/`fetcher.submit` are now stable across location changes, since we can handle relative routing via the `@remix-run/router` instance and get rid of our dependence on `useLocation()`. When using `BrowserRouter`, these hooks remain unstable across location changes because they still rely on `useLocation()`. ([#10336](https://github.com/remix-run/react-router/pull/10336))
400 - Updated dependencies:
401 - `@remix-run/router@1.6.0`
402
403 ## 6.10.0
404
405 ### Minor Changes
406
407 - Added support for [**Future Flags**](https://reactrouter.com/en/main/guides/api-development-strategy) in React Router. The first flag being introduced is `future.v7_normalizeFormMethod` which will normalize the exposed `useNavigation()/useFetcher()` `formMethod` fields as uppercase HTTP methods to align with the `fetch()` behavior. ([#10207](https://github.com/remix-run/react-router/pull/10207))
408
409 - When `future.v7_normalizeFormMethod === false` (default v6 behavior),
410 - `useNavigation().formMethod` is lowercase
411 - `useFetcher().formMethod` is lowercase
412 - When `future.v7_normalizeFormMethod === true`:
413 - `useNavigation().formMethod` is uppercase
414 - `useFetcher().formMethod` is uppercase
415
416 ### Patch Changes
417
418 - Fix route ID generation when using Fragments in `createRoutesFromElements` ([#10193](https://github.com/remix-run/react-router/pull/10193))
419 - Updated dependencies:
420 - `@remix-run/router@1.5.0`
421
422 ## 6.9.0
423
424 ### Minor Changes
425
426 - React Router now supports an alternative way to define your route `element` and `errorElement` fields as React Components instead of React Elements. You can instead pass a React Component to the new `Component` and `ErrorBoundary` fields if you choose. There is no functional difference between the two, so use whichever approach you prefer 😀. You shouldn't be defining both, but if you do `Component`/`ErrorBoundary` will "win". ([#10045](https://github.com/remix-run/react-router/pull/10045))
427
428 **Example JSON Syntax**
429
430 ```jsx
431 // Both of these work the same:
432 const elementRoutes = [{
433 path: '/',
434 element: <Home />,
435 errorElement: <HomeError />,
436 }]
437
438 const componentRoutes = [{
439 path: '/',
440 Component: Home,
441 ErrorBoundary: HomeError,
442 }]
443
444 function Home() { ... }
445 function HomeError() { ... }
446 ```
447
448 **Example JSX Syntax**
449
450 ```jsx
451 // Both of these work the same:
452 const elementRoutes = createRoutesFromElements(
453 <Route path='/' element={<Home />} errorElement={<HomeError /> } />
454 );
455
456 const componentRoutes = createRoutesFromElements(
457 <Route path='/' Component={Home} ErrorBoundary={HomeError} />
458 );
459
460 function Home() { ... }
461 function HomeError() { ... }
462 ```
463
464 - **Introducing Lazy Route Modules!** ([#10045](https://github.com/remix-run/react-router/pull/10045))
465
466 In order to keep your application bundles small and support code-splitting of your routes, we've introduced a new `lazy()` route property. This is an async function that resolves the non-route-matching portions of your route definition (`loader`, `action`, `element`/`Component`, `errorElement`/`ErrorBoundary`, `shouldRevalidate`, `handle`).
467
468 Lazy routes are resolved on initial load and during the `loading` or `submitting` phase of a navigation or fetcher call. You cannot lazily define route-matching properties (`path`, `index`, `children`) since we only execute your lazy route functions after we've matched known routes.
469
470 Your `lazy` functions will typically return the result of a dynamic import.
471
472 ```jsx
473 // In this example, we assume most folks land on the homepage so we include that
474 // in our critical-path bundle, but then we lazily load modules for /a and /b so
475 // they don't load until the user navigates to those routes
476 let routes = createRoutesFromElements(
477 <Route path="/" element={<Layout />}>
478 <Route index element={<Home />} />
479 <Route path="a" lazy={() => import("./a")} />
480 <Route path="b" lazy={() => import("./b")} />
481 </Route>
482 );
483 ```
484
485 Then in your lazy route modules, export the properties you want defined for the route:
486
487 ```jsx
488 export async function loader({ request }) {
489 let data = await fetchData(request);
490 return json(data);
491 }
492
493 // Export a `Component` directly instead of needing to create a React Element from it
494 export function Component() {
495 let data = useLoaderData();
496
497 return (
498 <>
499 <h1>You made it!</h1>
500 <p>{data}</p>
501 </>
502 );
503 }
504
505 // Export an `ErrorBoundary` directly instead of needing to create a React Element from it
506 export function ErrorBoundary() {
507 let error = useRouteError();
508 return isRouteErrorResponse(error) ? (
509 <h1>
510 {error.status} {error.statusText}
511 </h1>
512 ) : (
513 <h1>{error.message || error}</h1>
514 );
515 }
516 ```
517
518 An example of this in action can be found in the [`examples/lazy-loading-router-provider`](https://github.com/remix-run/react-router/tree/main/examples/lazy-loading-router-provider) directory of the repository.
519
520 🙌 Huge thanks to @rossipedia for the [Initial Proposal](https://github.com/remix-run/react-router/discussions/9826) and [POC Implementation](https://github.com/remix-run/react-router/pull/9830).
521
522 - Updated dependencies:
523 - `@remix-run/router@1.4.0`
524
525 ### Patch Changes
526
527 - Fix `generatePath` incorrectly applying parameters in some cases ([#10078](https://github.com/remix-run/react-router/pull/10078))
528 - Improve memoization for context providers to avoid unnecessary re-renders ([#9983](https://github.com/remix-run/react-router/pull/9983))
529
530 ## 6.8.2
531
532 ### Patch Changes
533
534 - Updated dependencies:
535 - `@remix-run/router@1.3.3`
536
537 ## 6.8.1
538
539 ### Patch Changes
540
541 - Remove inaccurate console warning for POP navigations and update active blocker logic ([#10030](https://github.com/remix-run/react-router/pull/10030))
542 - Updated dependencies:
543 - `@remix-run/router@1.3.2`
544
545 ## 6.8.0
546
547 ### Patch Changes
548
549 - Updated dependencies:
550 - `@remix-run/router@1.3.1`
551
552 ## 6.7.0
553
554 ### Minor Changes
555
556 - Add `unstable_useBlocker` hook for blocking navigations within the app's location origin ([#9709](https://github.com/remix-run/react-router/pull/9709))
557
558 ### Patch Changes
559
560 - Fix `generatePath` when optional params are present ([#9764](https://github.com/remix-run/react-router/pull/9764))
561 - Update `<Await>` to accept `ReactNode` as children function return result ([#9896](https://github.com/remix-run/react-router/pull/9896))
562 - Updated dependencies:
563 - `@remix-run/router@1.3.0`
564
565 ## 6.6.2
566
567 ### Patch Changes
568
569 - Ensure `useId` consistency during SSR ([#9805](https://github.com/remix-run/react-router/pull/9805))
570
571 ## 6.6.1
572
573 ### Patch Changes
574
575 - Updated dependencies:
576 - `@remix-run/router@1.2.1`
577
578 ## 6.6.0
579
580 ### Patch Changes
581
582 - Prevent `useLoaderData` usage in `errorElement` ([#9735](https://github.com/remix-run/react-router/pull/9735))
583 - Updated dependencies:
584 - `@remix-run/router@1.2.0`
585
586 ## 6.5.0
587
588 This release introduces support for [Optional Route Segments](https://github.com/remix-run/react-router/issues/9546). Now, adding a `?` to the end of any path segment will make that entire segment optional. This works for both static segments and dynamic parameters.
589
590 **Optional Params Examples**
591
592 - `<Route path=":lang?/about>` will match:
593 - `/:lang/about`
594 - `/about`
595 - `<Route path="/multistep/:widget1?/widget2?/widget3?">` will match:
596 - `/multistep`
597 - `/multistep/:widget1`
598 - `/multistep/:widget1/:widget2`
599 - `/multistep/:widget1/:widget2/:widget3`
600
601 **Optional Static Segment Example**
602
603 - `<Route path="/home?">` will match:
604 - `/`
605 - `/home`
606 - `<Route path="/fr?/about">` will match:
607 - `/about`
608 - `/fr/about`
609
610 ### Minor Changes
611
612 - Allows optional routes and optional static segments ([#9650](https://github.com/remix-run/react-router/pull/9650))
613
614 ### Patch Changes
615
616 - Stop incorrectly matching on partial named parameters, i.e. `<Route path="prefix-:param">`, to align with how splat parameters work. If you were previously relying on this behavior then it's recommended to extract the static portion of the path at the `useParams` call site: ([#9506](https://github.com/remix-run/react-router/pull/9506))
617
618 ```jsx
619 // Old behavior at URL /prefix-123
620 }>
621
622 function Comp() {
623 let params = useParams(); // { id: '123' }
624 let id = params.id; // "123"
625 ...
626 }
627
628 // New behavior at URL /prefix-123
629 }>
630
631 function Comp() {
632 let params = useParams(); // { id: 'prefix-123' }
633 let id = params.id.replace(/^prefix-/, ''); // "123"
634 ...
635 }
636 ```
637
638 - Updated dependencies:
639 - `@remix-run/router@1.1.0`
640
641 ## 6.4.5
642
643 ### Patch Changes
644
645 - Updated dependencies:
646 - `@remix-run/router@1.0.5`
647
648 ## 6.4.4
649
650 ### Patch Changes
651
652 - Updated dependencies:
653 - `@remix-run/router@1.0.4`
654
655 ## 6.4.3
656
657 ### Patch Changes
658
659 - `useRoutes` should be able to return `null` when passing `locationArg` ([#9485](https://github.com/remix-run/react-router/pull/9485))
660 - fix `initialEntries` type in `createMemoryRouter` ([#9498](https://github.com/remix-run/react-router/pull/9498))
661 - Updated dependencies:
662 - `@remix-run/router@1.0.3`
663
664 ## 6.4.2
665
666 ### Patch Changes
667
668 - Fix `IndexRouteObject` and `NonIndexRouteObject` types to make `hasErrorElement` optional ([#9394](https://github.com/remix-run/react-router/pull/9394))
669 - Enhance console error messages for invalid usage of data router hooks ([#9311](https://github.com/remix-run/react-router/pull/9311))
670 - If an index route has children, it will result in a runtime error. We have strengthened our `RouteObject`/`RouteProps` types to surface the error in TypeScript. ([#9366](https://github.com/remix-run/react-router/pull/9366))
671 - Updated dependencies:
672 - `@remix-run/router@1.0.2`
673
674 ## 6.4.1
675
676 ### Patch Changes
677
678 - Preserve state from `initialEntries` ([#9288](https://github.com/remix-run/react-router/pull/9288))
679 - Updated dependencies:
680 - `@remix-run/router@1.0.1`
681
682 ## 6.4.0
683
684 Whoa this is a big one! `6.4.0` brings all the data loading and mutation APIs over from Remix. Here's a quick high level overview, but it's recommended you go check out the [docs](https://reactrouter.com), especially the [feature overview](https://reactrouter.com/start/overview) and the [tutorial](https://reactrouter.com/start/tutorial).
685
686 **New APIs**
687
688 - Create your router with `createMemoryRouter`
689 - Render your router with `<RouterProvider>`
690 - Load data with a Route `loader` and mutate with a Route `action`
691 - Handle errors with Route `errorElement`
692 - Defer non-critical data with `defer` and `Await`
693
694 **Bug Fixes**
695
696 - Path resolution is now trailing slash agnostic (#8861)
697 - `useLocation` returns the scoped location inside a `<Routes location>` component (#9094)
698
699 **Updated Dependencies**
700
701 - `@remix-run/router@1.0.0`