| 1 | # `react-router`
|
| 2 |
|
| 3 | ## 7.1.3
|
| 4 |
|
| 5 | _No changes_
|
| 6 |
|
| 7 | ## 7.1.2
|
| 8 |
|
| 9 | ### Patch Changes
|
| 10 |
|
| 11 | - Fix issue with fetcher data cleanup in the data layer on fetcher unmount ([#12681](https://github.com/remix-run/react-router/pull/12681))
|
| 12 | - Do not rely on `symbol` for filtering out `redirect` responses from loader data ([#12694](https://github.com/remix-run/react-router/pull/12694))
|
| 13 |
|
| 14 | Previously, some projects were getting type checking errors like:
|
| 15 |
|
| 16 | ```ts
|
| 17 | error TS4058: Return type of exported function has or is using name 'redirectSymbol' from external module "node_modules/..." but cannot be named.
|
| 18 | ```
|
| 19 |
|
| 20 | Now that `symbol`s are not used for the `redirect` response type, these errors should no longer be present.
|
| 21 |
|
| 22 | ## 7.1.1
|
| 23 |
|
| 24 | _No changes_
|
| 25 |
|
| 26 | ## 7.1.0
|
| 27 |
|
| 28 | ### Patch Changes
|
| 29 |
|
| 30 | - Throw unwrapped single fetch redirect to align with pre-single fetch behavior ([#12506](https://github.com/remix-run/react-router/pull/12506))
|
| 31 | - Ignore redirects when inferring loader data types ([#12527](https://github.com/remix-run/react-router/pull/12527))
|
| 32 | - Remove `<Link prefetch>` warning which suffers from false positives in a lazy route discovery world ([#12485](https://github.com/remix-run/react-router/pull/12485))
|
| 33 |
|
| 34 | ## 7.0.2
|
| 35 |
|
| 36 | ### Patch Changes
|
| 37 |
|
| 38 | - temporarily only use one build in export map so packages can have a peer dependency on react router ([#12437](https://github.com/remix-run/react-router/pull/12437))
|
| 39 | - Generate wide `matches` and `params` types for current route and child routes ([#12397](https://github.com/remix-run/react-router/pull/12397))
|
| 40 |
|
| 41 | At runtime, `matches` includes child route matches and `params` include child route path parameters.
|
| 42 | But previously, we only generated types for parent routes in `matches`; for `params`, we only considered the parent routes and the current route.
|
| 43 | To align our generated types more closely to the runtime behavior, we now generate more permissive, wider types when accessing child route information.
|
| 44 |
|
| 45 | ## 7.0.1
|
| 46 |
|
| 47 | _No changes_
|
| 48 |
|
| 49 | ## 7.0.0
|
| 50 |
|
| 51 | ### Major Changes
|
| 52 |
|
| 53 | - Remove the original `defer` implementation in favor of using raw promises via single fetch and `turbo-stream`. This removes these exports from React Router: ([#11744](https://github.com/remix-run/react-router/pull/11744))
|
| 54 |
|
| 55 | - `defer`
|
| 56 | - `AbortedDeferredError`
|
| 57 | - `type TypedDeferredData`
|
| 58 | - `UNSAFE_DeferredData`
|
| 59 | - `UNSAFE_DEFERRED_SYMBOL`,
|
| 60 |
|
| 61 | - - Collapse `@remix-run/router` into `react-router` ([#11505](https://github.com/remix-run/react-router/pull/11505))
|
| 62 | - Collapse `react-router-dom` into `react-router`
|
| 63 | - Collapse `@remix-run/server-runtime` into `react-router`
|
| 64 | - Collapse `@remix-run/testing` into `react-router`
|
| 65 |
|
| 66 | - Remove single_fetch future flag. ([#11522](https://github.com/remix-run/react-router/pull/11522))
|
| 67 |
|
| 68 | - Drop support for Node 16, React Router SSR now requires Node 18 or higher ([#11391](https://github.com/remix-run/react-router/pull/11391))
|
| 69 |
|
| 70 | - Remove `future.v7_startTransition` flag ([#11696](https://github.com/remix-run/react-router/pull/11696))
|
| 71 |
|
| 72 | - - Expose the underlying router promises from the following APIs for compsition in React 19 APIs: ([#11521](https://github.com/remix-run/react-router/pull/11521))
|
| 73 | - `useNavigate()`
|
| 74 | - `useSubmit`
|
| 75 | - `useFetcher().load`
|
| 76 | - `useFetcher().submit`
|
| 77 | - `useRevalidator.revalidate`
|
| 78 |
|
| 79 | - Remove `future.v7_normalizeFormMethod` future flag ([#11697](https://github.com/remix-run/react-router/pull/11697))
|
| 80 |
|
| 81 | - For Remix consumers migrating to React Router, the `crypto` global from the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is now required when using cookie and session APIs. This means that the following APIs are provided from `react-router` rather than platform-specific packages: ([#11837](https://github.com/remix-run/react-router/pull/11837))
|
| 82 |
|
| 83 | - `createCookie`
|
| 84 | - `createCookieSessionStorage`
|
| 85 | - `createMemorySessionStorage`
|
| 86 | - `createSessionStorage`
|
| 87 |
|
| 88 | For consumers running older versions of Node, the `installGlobals` function from `@remix-run/node` has been updated to define `globalThis.crypto`, using [Node's `require('node:crypto').webcrypto` implementation.](https://nodejs.org/api/webcrypto.html)
|
| 89 |
|
| 90 | Since platform-specific packages no longer need to implement this API, the following low-level APIs have been removed:
|
| 91 |
|
| 92 | - `createCookieFactory`
|
| 93 | - `createSessionStorageFactory`
|
| 94 | - `createCookieSessionStorageFactory`
|
| 95 | - `createMemorySessionStorageFactory`
|
| 96 |
|
| 97 | - Imports/Exports cleanup ([#11840](https://github.com/remix-run/react-router/pull/11840))
|
| 98 |
|
| 99 | - Removed the following exports that were previously public API from `@remix-run/router`
|
| 100 | - types
|
| 101 | - `AgnosticDataIndexRouteObject`
|
| 102 | - `AgnosticDataNonIndexRouteObject`
|
| 103 | - `AgnosticDataRouteMatch`
|
| 104 | - `AgnosticDataRouteObject`
|
| 105 | - `AgnosticIndexRouteObject`
|
| 106 | - `AgnosticNonIndexRouteObject`
|
| 107 | - `AgnosticRouteMatch`
|
| 108 | - `AgnosticRouteObject`
|
| 109 | - `TrackedPromise`
|
| 110 | - `unstable_AgnosticPatchRoutesOnMissFunction`
|
| 111 | - `Action` -> exported as `NavigationType` via `react-router`
|
| 112 | - `Router` exported as `DataRouter` to differentiate from RR's `<Router>`
|
| 113 | - API
|
| 114 | - `getToPathname` (`@private`)
|
| 115 | - `joinPaths` (`@private`)
|
| 116 | - `normalizePathname` (`@private`)
|
| 117 | - `resolveTo` (`@private`)
|
| 118 | - `stripBasename` (`@private`)
|
| 119 | - `createBrowserHistory` -> in favor of `createBrowserRouter`
|
| 120 | - `createHashHistory` -> in favor of `createHashRouter`
|
| 121 | - `createMemoryHistory` -> in favor of `createMemoryRouter`
|
| 122 | - `createRouter`
|
| 123 | - `createStaticHandler` -> in favor of wrapper `createStaticHandler` in RR Dom
|
| 124 | - `getStaticContextFromError`
|
| 125 | - Removed the following exports that were previously public API from `react-router`
|
| 126 | - `Hash`
|
| 127 | - `Pathname`
|
| 128 | - `Search`
|
| 129 |
|
| 130 | - update minimum node version to 18 ([#11690](https://github.com/remix-run/react-router/pull/11690))
|
| 131 |
|
| 132 | - Remove `future.v7_prependBasename` from the ionternalized `@remix-run/router` package ([#11726](https://github.com/remix-run/react-router/pull/11726))
|
| 133 |
|
| 134 | - Migrate Remix type generics to React Router ([#12180](https://github.com/remix-run/react-router/pull/12180))
|
| 135 |
|
| 136 | - These generics are provided for Remix v2 migration purposes
|
| 137 | - These generics and the APIs they exist on should be considered informally deprecated in favor of the new `Route.*` types
|
| 138 | - Anyone migrating from React Router v6 should probably not leverage these new generics and should migrate straight to the `Route.*` types
|
| 139 | - For React Router v6 users, these generics are new and should not impact your app, with one exception
|
| 140 | - `useFetcher` previously had an optional generic (used primarily by Remix v2) that expected the data type
|
| 141 | - This has been updated in v7 to expect the type of the function that generates the data (i.e., `typeof loader`/`typeof action`)
|
| 142 | - Therefore, you should update your usages:
|
| 143 | - ❌ `useFetcher<LoaderData>()`
|
| 144 | - ✅ `useFetcher<typeof loader>()`
|
| 145 |
|
| 146 | - Remove `future.v7_throwAbortReason` from internalized `@remix-run/router` package ([#11728](https://github.com/remix-run/react-router/pull/11728))
|
| 147 |
|
| 148 | - Add `exports` field to all packages ([#11675](https://github.com/remix-run/react-router/pull/11675))
|
| 149 |
|
| 150 | - node package no longer re-exports from react-router ([#11702](https://github.com/remix-run/react-router/pull/11702))
|
| 151 |
|
| 152 | - renamed RemixContext to FrameworkContext ([#11705](https://github.com/remix-run/react-router/pull/11705))
|
| 153 |
|
| 154 | - updates the minimum React version to 18 ([#11689](https://github.com/remix-run/react-router/pull/11689))
|
| 155 |
|
| 156 | - PrefetchPageDescriptor replaced by PageLinkDescriptor ([#11960](https://github.com/remix-run/react-router/pull/11960))
|
| 157 |
|
| 158 | - - Consolidate types previously duplicated across `@remix-run/router`, `@remix-run/server-runtime`, and `@remix-run/react` now that they all live in `react-router` ([#12177](https://github.com/remix-run/react-router/pull/12177))
|
| 159 | - Examples: `LoaderFunction`, `LoaderFunctionArgs`, `ActionFunction`, `ActionFunctionArgs`, `DataFunctionArgs`, `RouteManifest`, `LinksFunction`, `Route`, `EntryRoute`
|
| 160 | - The `RouteManifest` type used by the "remix" code is now slightly stricter because it is using the former `@remix-run/router` `RouteManifest`
|
| 161 | - `Record<string, Route> -> Record<string, Route | undefined>`
|
| 162 | - Removed `AppData` type in favor of inlining `unknown` in the few locations it was used
|
| 163 | - Removed `ServerRuntimeMeta*` types in favor of the `Meta*` types they were duplicated from
|
| 164 |
|
| 165 | - - Remove the `future.v7_partialHydration` flag ([#11725](https://github.com/remix-run/react-router/pull/11725))
|
| 166 | - This also removes the `<RouterProvider fallbackElement>` prop
|
| 167 | - To migrate, move the `fallbackElement` to a `hydrateFallbackElement`/`HydrateFallback` on your root route
|
| 168 | - Also worth nothing there is a related breaking changer with this future flag:
|
| 169 | - Without `future.v7_partialHydration` (when using `fallbackElement`), `state.navigation` was populated during the initial load
|
| 170 | - With `future.v7_partialHydration`, `state.navigation` remains in an `"idle"` state during the initial load
|
| 171 |
|
| 172 | - Remove `v7_relativeSplatPath` future flag ([#11695](https://github.com/remix-run/react-router/pull/11695))
|
| 173 |
|
| 174 | - Drop support for Node 18, update minimum Node vestion to 20 ([#12171](https://github.com/remix-run/react-router/pull/12171))
|
| 175 |
|
| 176 | - Remove `installGlobals()` as this should no longer be necessary
|
| 177 |
|
| 178 | - Remove remaining future flags ([#11820](https://github.com/remix-run/react-router/pull/11820))
|
| 179 |
|
| 180 | - React Router `v7_skipActionErrorRevalidation`
|
| 181 | - Remix `v3_fetcherPersist`, `v3_relativeSplatPath`, `v3_throwAbortReason`
|
| 182 |
|
| 183 | - rename createRemixStub to createRoutesStub ([#11692](https://github.com/remix-run/react-router/pull/11692))
|
| 184 |
|
| 185 | - Remove `@remix-run/router` deprecated `detectErrorBoundary` option in favor of `mapRouteProperties` ([#11751](https://github.com/remix-run/react-router/pull/11751))
|
| 186 |
|
| 187 | - Add `react-router/dom` subpath export to properly enable `react-dom` as an optional `peerDependency` ([#11851](https://github.com/remix-run/react-router/pull/11851))
|
| 188 |
|
| 189 | - This ensures that we don't blindly `import ReactDOM from "react-dom"` in `<RouterProvider>` in order to access `ReactDOM.flushSync()`, since that would break `createMemoryRouter` use cases in non-DOM environments
|
| 190 | - DOM environments should import from `react-router/dom` to get the proper component that makes `ReactDOM.flushSync()` available:
|
| 191 | - If you are using the Vite plugin, use this in your `entry.client.tsx`:
|
| 192 | - `import { HydratedRouter } from 'react-router/dom'`
|
| 193 | - If you are not using the Vite plugin and are manually calling `createBrowserRouter`/`createHashRouter`:
|
| 194 | - `import { RouterProvider } from "react-router/dom"`
|
| 195 |
|
| 196 | - Remove `future.v7_fetcherPersist` flag ([#11731](https://github.com/remix-run/react-router/pull/11731))
|
| 197 |
|
| 198 | - Update `cookie` dependency to `^1.0.1` - please see the [release notes](https://github.com/jshttp/cookie/releases) for any breaking changes ([#12172](https://github.com/remix-run/react-router/pull/12172))
|
| 199 |
|
| 200 | ### Minor Changes
|
| 201 |
|
| 202 | - - Add support for `prerender` config in the React Router vite plugin, to support existing SSG use-cases ([#11539](https://github.com/remix-run/react-router/pull/11539))
|
| 203 | - You can use the `prerender` config to pre-render your `.html` and `.data` files at build time and then serve them statically at runtime (either from a running server or a CDN)
|
| 204 | - `prerender` can either be an array of string paths, or a function (sync or async) that returns an array of strings so that you can dynamically generate the paths by talking to your CMS, etc.
|
| 205 |
|
| 206 | ```ts
|
| 207 | // react-router.config.ts
|
| 208 | import type { Config } from "@react-router/dev/config";
|
| 209 |
|
| 210 | export default {
|
| 211 | async prerender() {
|
| 212 | let slugs = await fakeGetSlugsFromCms();
|
| 213 | // Prerender these paths into `.html` files at build time, and `.data`
|
| 214 | // files if they have loaders
|
| 215 | return ["/", "/about", ...slugs.map((slug) => `/product/${slug}`)];
|
| 216 | },
|
| 217 | } satisfies Config;
|
| 218 |
|
| 219 | async function fakeGetSlugsFromCms() {
|
| 220 | await new Promise((r) => setTimeout(r, 1000));
|
| 221 | return ["shirt", "hat"];
|
| 222 | }
|
| 223 | ```
|
| 224 |
|
| 225 | - Params, loader data, and action data as props for route component exports ([#11961](https://github.com/remix-run/react-router/pull/11961))
|
| 226 |
|
| 227 | ```tsx
|
| 228 | export default function Component({ params, loaderData, actionData }) {}
|
| 229 |
|
| 230 | export function HydrateFallback({ params }) {}
|
| 231 | export function ErrorBoundary({ params, loaderData, actionData }) {}
|
| 232 | ```
|
| 233 |
|
| 234 | - Remove duplicate `RouterProvider` impliementations ([#11679](https://github.com/remix-run/react-router/pull/11679))
|
| 235 |
|
| 236 | - ### Typesafety improvements ([#12019](https://github.com/remix-run/react-router/pull/12019))
|
| 237 |
|
| 238 | React Router now generates types for each of your route modules.
|
| 239 | You can access those types by importing them from `./+types.<route filename without extension>`.
|
| 240 | For example:
|
| 241 |
|
| 242 | ```ts
|
| 243 | // app/routes/product.tsx
|
| 244 | import type * as Route from "./+types.product";
|
| 245 |
|
| 246 | export function loader({ params }: Route.LoaderArgs) {}
|
| 247 |
|
| 248 | export default function Component({ loaderData }: Route.ComponentProps) {}
|
| 249 | ```
|
| 250 |
|
| 251 | This initial implementation targets type inference for:
|
| 252 |
|
| 253 | - `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
|
| 254 | - `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
|
| 255 | - `ActionData` : Action data from `action` and/or `clientAction` within your route module
|
| 256 |
|
| 257 | In the future, we plan to add types for the rest of the route module exports: `meta`, `links`, `headers`, `shouldRevalidate`, etc.
|
| 258 | We also plan to generate types for typesafe `Link`s:
|
| 259 |
|
| 260 | ```tsx
|
| 261 | <Link to="/products/:id" params={{ id: 1 }} />
|
| 262 | // ^^^^^^^^^^^^^ ^^^^^^^^^
|
| 263 | // typesafe `to` and `params` based on the available routes in your app
|
| 264 | ```
|
| 265 |
|
| 266 | Check out our docs for more:
|
| 267 |
|
| 268 | - [_Explanations > Type Safety_](https://reactrouter.com/dev/guides/explanation/type-safety)
|
| 269 | - [_How-To > Setting up type safety_](https://reactrouter.com/dev/guides/how-to/setting-up-type-safety)
|
| 270 |
|
| 271 | - Stabilize `unstable_dataStrategy` ([#11969](https://github.com/remix-run/react-router/pull/11969))
|
| 272 |
|
| 273 | - Stabilize `unstable_patchRoutesOnNavigation` ([#11970](https://github.com/remix-run/react-router/pull/11970))
|
| 274 |
|
| 275 | ### Patch Changes
|
| 276 |
|
| 277 | - No changes ([`506329c4e`](https://github.com/remix-run/react-router/commit/506329c4e2e7aba9837cbfa44df6103b49423745))
|
| 278 |
|
| 279 | - chore: re-enable development warnings through a `development` exports condition. ([#12269](https://github.com/remix-run/react-router/pull/12269))
|
| 280 |
|
| 281 | - Remove unstable upload handler. ([#12015](https://github.com/remix-run/react-router/pull/12015))
|
| 282 |
|
| 283 | - Remove unneeded dependency on @web3-storage/multipart-parser ([#12274](https://github.com/remix-run/react-router/pull/12274))
|
| 284 |
|
| 285 | - Fix redirects returned from loaders/actions using `data()` ([#12021](https://github.com/remix-run/react-router/pull/12021))
|
| 286 |
|
| 287 | - fix(react-router): (v7) fix static prerender of non-ascii characters ([#12161](https://github.com/remix-run/react-router/pull/12161))
|
| 288 |
|
| 289 | - Replace `substr` with `substring` ([#12080](https://github.com/remix-run/react-router/pull/12080))
|
| 290 |
|
| 291 | - Remove the deprecated `json` utility ([#12146](https://github.com/remix-run/react-router/pull/12146))
|
| 292 |
|
| 293 | - You can use [`Response.json`](https://developer.mozilla.org/en-US/docs/Web/API/Response/json_static) if you still need to construct JSON responses in your app
|
| 294 |
|
| 295 | - Remove unneeded dependency on source-map ([#12275](https://github.com/remix-run/react-router/pull/12275))
|
| 296 |
|
| 297 | ## 6.28.0
|
| 298 |
|
| 299 | ### Minor Changes
|
| 300 |
|
| 301 | - - Log deprecation warnings for v7 flags ([#11750](https://github.com/remix-run/react-router/pull/11750))
|
| 302 | - Add deprecation warnings to `json`/`defer` in favor of returning raw objects
|
| 303 | - These methods will be removed in React Router v7
|
| 304 |
|
| 305 | ### Patch Changes
|
| 306 |
|
| 307 | - Update JSDoc URLs for new website structure (add /v6/ segment) ([#12141](https://github.com/remix-run/react-router/pull/12141))
|
| 308 | - Updated dependencies:
|
| 309 | - `@remix-run/router@1.21.0`
|
| 310 |
|
| 311 | ## 6.27.0
|
| 312 |
|
| 313 | ### Minor Changes
|
| 314 |
|
| 315 | - Stabilize `unstable_patchRoutesOnNavigation` ([#11973](https://github.com/remix-run/react-router/pull/11973))
|
| 316 | - Add new `PatchRoutesOnNavigationFunctionArgs` type for convenience ([#11967](https://github.com/remix-run/react-router/pull/11967))
|
| 317 | - Stabilize `unstable_dataStrategy` ([#11974](https://github.com/remix-run/react-router/pull/11974))
|
| 318 | - Stabilize the `unstable_flushSync` option for navigations and fetchers ([#11989](https://github.com/remix-run/react-router/pull/11989))
|
| 319 | - Stabilize the `unstable_viewTransition` option for navigations and the corresponding `unstable_useViewTransitionState` hook ([#11989](https://github.com/remix-run/react-router/pull/11989))
|
| 320 |
|
| 321 | ### Patch Changes
|
| 322 |
|
| 323 | - Fix bug when submitting to the current contextual route (parent route with an index child) when an `?index` param already exists from a prior submission ([#12003](https://github.com/remix-run/react-router/pull/12003))
|
| 324 |
|
| 325 | - Fix `useFormAction` bug - when removing `?index` param it would not keep other non-Remix `index` params ([#12003](https://github.com/remix-run/react-router/pull/12003))
|
| 326 |
|
| 327 | - Fix types for `RouteObject` within `PatchRoutesOnNavigationFunction`'s `patch` method so it doesn't expect agnostic route objects passed to `patch` ([#11967](https://github.com/remix-run/react-router/pull/11967))
|
| 328 |
|
| 329 | - Updated dependencies:
|
| 330 | - `@remix-run/router@1.20.0`
|
| 331 |
|
| 332 | ## 6.26.2
|
| 333 |
|
| 334 | ### Patch Changes
|
| 335 |
|
| 336 | - Updated dependencies:
|
| 337 | - `@remix-run/router@1.19.2`
|
| 338 |
|
| 339 | ## 6.26.1
|
| 340 |
|
| 341 | ### Patch Changes
|
| 342 |
|
| 343 | - Rename `unstable_patchRoutesOnMiss` to `unstable_patchRoutesOnNavigation` to match new behavior ([#11888](https://github.com/remix-run/react-router/pull/11888))
|
| 344 | - Updated dependencies:
|
| 345 | - `@remix-run/router@1.19.1`
|
| 346 |
|
| 347 | ## 6.26.0
|
| 348 |
|
| 349 | ### Minor Changes
|
| 350 |
|
| 351 | - Add a new `replace(url, init?)` alternative to `redirect(url, init?)` that performs a `history.replaceState` instead of a `history.pushState` on client-side navigation redirects ([#11811](https://github.com/remix-run/react-router/pull/11811))
|
| 352 |
|
| 353 | ### Patch Changes
|
| 354 |
|
| 355 | - Fix initial hydration behavior when using `future.v7_partialHydration` along with `unstable_patchRoutesOnMiss` ([#11838](https://github.com/remix-run/react-router/pull/11838))
|
| 356 | - During initial hydration, `router.state.matches` will now include any partial matches so that we can render ancestor `HydrateFallback` components
|
| 357 | - Updated dependencies:
|
| 358 | - `@remix-run/router@1.19.0`
|
| 359 |
|
| 360 | ## 6.25.1
|
| 361 |
|
| 362 | No significant changes to this package were made in this release. [See the repo `CHANGELOG.md`](https://github.com/remix-run/react-router/blob/main/CHANGELOG.md) for an overview of all changes in v6.25.1.
|
| 363 |
|
| 364 | ## 6.25.0
|
| 365 |
|
| 366 | ### Minor Changes
|
| 367 |
|
| 368 | - Stabilize `future.unstable_skipActionErrorRevalidation` as `future.v7_skipActionErrorRevalidation` ([#11769](https://github.com/remix-run/react-router/pull/11769))
|
| 369 | - When this flag is enabled, actions will not automatically trigger a revalidation if they return/throw a `Response` with a `4xx`/`5xx` status code
|
| 370 | - You may still opt-into revalidation via `shouldRevalidate`
|
| 371 | - This also changes `shouldRevalidate`'s `unstable_actionStatus` parameter to `actionStatus`
|
| 372 |
|
| 373 | ### Patch Changes
|
| 374 |
|
| 375 | - Fix regression and properly decode paths inside `useMatch` so matches/params reflect decoded params ([#11789](https://github.com/remix-run/react-router/pull/11789))
|
| 376 | - Updated dependencies:
|
| 377 | - `@remix-run/router@1.18.0`
|
| 378 |
|
| 379 | ## 6.24.1
|
| 380 |
|
| 381 | ### Patch Changes
|
| 382 |
|
| 383 | - When using `future.v7_relativeSplatPath`, properly resolve relative paths in splat routes that are children of pathless routes ([#11633](https://github.com/remix-run/react-router/pull/11633))
|
| 384 | - Updated dependencies:
|
| 385 | - `@remix-run/router@1.17.1`
|
| 386 |
|
| 387 | ## 6.24.0
|
| 388 |
|
| 389 | ### Minor Changes
|
| 390 |
|
| 391 | - Add support for Lazy Route Discovery (a.k.a. Fog of War) ([#11626](https://github.com/remix-run/react-router/pull/11626))
|
| 392 | - RFC: <https://github.com/remix-run/react-router/discussions/11113>
|
| 393 | - `unstable_patchRoutesOnMiss` docs: <https://reactrouter.com/v6/routers/create-browser-router>
|
| 394 |
|
| 395 | ### Patch Changes
|
| 396 |
|
| 397 | - Updated dependencies:
|
| 398 | - `@remix-run/router@1.17.0`
|
| 399 |
|
| 400 | ## 6.23.1
|
| 401 |
|
| 402 | ### Patch Changes
|
| 403 |
|
| 404 | - allow undefined to be resolved with `<Await>` ([#11513](https://github.com/remix-run/react-router/pull/11513))
|
| 405 | - Updated dependencies:
|
| 406 | - `@remix-run/router@1.16.1`
|
| 407 |
|
| 408 | ## 6.23.0
|
| 409 |
|
| 410 | ### Minor Changes
|
| 411 |
|
| 412 | - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098))
|
| 413 | - This option allows Data Router applications to take control over the approach for executing route loaders and actions
|
| 414 | - 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
|
| 415 |
|
| 416 | ### Patch Changes
|
| 417 |
|
| 418 | - Updated dependencies:
|
| 419 | - `@remix-run/router@1.16.0`
|
| 420 |
|
| 421 | ## 6.22.3
|
| 422 |
|
| 423 | ### Patch Changes
|
| 424 |
|
| 425 | - Updated dependencies:
|
| 426 | - `@remix-run/router@1.15.3`
|
| 427 |
|
| 428 | ## 6.22.2
|
| 429 |
|
| 430 | ### Patch Changes
|
| 431 |
|
| 432 | - Updated dependencies:
|
| 433 | - `@remix-run/router@1.15.2`
|
| 434 |
|
| 435 | ## 6.22.1
|
| 436 |
|
| 437 | ### Patch Changes
|
| 438 |
|
| 439 | - Fix encoding/decoding issues with pre-encoded dynamic parameter values ([#11199](https://github.com/remix-run/react-router/pull/11199))
|
| 440 | - Updated dependencies:
|
| 441 | - `@remix-run/router@1.15.1`
|
| 442 |
|
| 443 | ## 6.22.0
|
| 444 |
|
| 445 | ### Patch Changes
|
| 446 |
|
| 447 | - Updated dependencies:
|
| 448 | - `@remix-run/router@1.15.0`
|
| 449 |
|
| 450 | ## 6.21.3
|
| 451 |
|
| 452 | ### Patch Changes
|
| 453 |
|
| 454 | - Remove leftover `unstable_` prefix from `Blocker`/`BlockerFunction` types ([#11187](https://github.com/remix-run/react-router/pull/11187))
|
| 455 |
|
| 456 | ## 6.21.2
|
| 457 |
|
| 458 | ### Patch Changes
|
| 459 |
|
| 460 | - Updated dependencies:
|
| 461 | - `@remix-run/router@1.14.2`
|
| 462 |
|
| 463 | ## 6.21.1
|
| 464 |
|
| 465 | ### Patch Changes
|
| 466 |
|
| 467 | - 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))
|
| 468 | - Updated dependencies:
|
| 469 | - `@remix-run/router@1.14.1`
|
| 470 |
|
| 471 | ## 6.21.0
|
| 472 |
|
| 473 | ### Minor Changes
|
| 474 |
|
| 475 | - 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))
|
| 476 |
|
| 477 | 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))
|
| 478 |
|
| 479 | **The Bug**
|
| 480 | 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.
|
| 481 |
|
| 482 | **The Background**
|
| 483 | 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:
|
| 484 |
|
| 485 | ```jsx
|
| 486 | <BrowserRouter>
|
| 487 | <Routes>
|
| 488 | <Route path="/" element={<Home />} />
|
| 489 | <Route path="dashboard/*" element={<Dashboard />} />
|
| 490 | </Routes>
|
| 491 | </BrowserRouter>
|
| 492 | ```
|
| 493 |
|
| 494 | Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
|
| 495 |
|
| 496 | ```jsx
|
| 497 | function Dashboard() {
|
| 498 | return (
|
| 499 | <div>
|
| 500 | <h2>Dashboard</h2>
|
| 501 | <nav>
|
| 502 | <Link to="/">Dashboard Home</Link>
|
| 503 | <Link to="team">Team</Link>
|
| 504 | <Link to="projects">Projects</Link>
|
| 505 | </nav>
|
| 506 |
|
| 507 | <Routes>
|
| 508 | <Route path="/" element={<DashboardHome />} />
|
| 509 | <Route path="team" element={<DashboardTeam />} />
|
| 510 | <Route path="projects" element={<DashboardProjects />} />
|
| 511 | </Routes>
|
| 512 | </div>
|
| 513 | );
|
| 514 | }
|
| 515 | ```
|
| 516 |
|
| 517 | 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.
|
| 518 |
|
| 519 | **The Problem**
|
| 520 |
|
| 521 | 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 `"."`:
|
| 522 |
|
| 523 | ```jsx
|
| 524 | // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
|
| 525 | function DashboardTeam() {
|
| 526 | // ❌ This is broken and results in <a href="/dashboard">
|
| 527 | return <Link to=".">A broken link to the Current URL</Link>;
|
| 528 |
|
| 529 | // ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
|
| 530 | return <Link to="./team">A broken link to the Current URL</Link>;
|
| 531 | }
|
| 532 | ```
|
| 533 |
|
| 534 | 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.
|
| 535 |
|
| 536 | Even worse, consider a nested splat route configuration:
|
| 537 |
|
| 538 | ```jsx
|
| 539 | <BrowserRouter>
|
| 540 | <Routes>
|
| 541 | <Route path="dashboard">
|
| 542 | <Route path="*" element={<Dashboard />} />
|
| 543 | </Route>
|
| 544 | </Routes>
|
| 545 | </BrowserRouter>
|
| 546 | ```
|
| 547 |
|
| 548 | Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
|
| 549 |
|
| 550 | 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:
|
| 551 |
|
| 552 | ```jsx
|
| 553 | let router = createBrowserRouter({
|
| 554 | path: "/dashboard",
|
| 555 | children: [
|
| 556 | {
|
| 557 | path: "*",
|
| 558 | action: dashboardAction,
|
| 559 | Component() {
|
| 560 | // ❌ This form is broken! It throws a 405 error when it submits because
|
| 561 | // it tries to submit to /dashboard (without the splat value) and the parent
|
| 562 | // `/dashboard` route doesn't have an action
|
| 563 | return <Form method="post">...</Form>;
|
| 564 | },
|
| 565 | },
|
| 566 | ],
|
| 567 | });
|
| 568 | ```
|
| 569 |
|
| 570 | 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.
|
| 571 |
|
| 572 | **The Solution**
|
| 573 | 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:
|
| 574 |
|
| 575 | ```jsx
|
| 576 | <BrowserRouter>
|
| 577 | <Routes>
|
| 578 | <Route path="dashboard">
|
| 579 | <Route index path="*" element={<Dashboard />} />
|
| 580 | </Route>
|
| 581 | </Routes>
|
| 582 | </BrowserRouter>
|
| 583 |
|
| 584 | function Dashboard() {
|
| 585 | return (
|
| 586 | <div>
|
| 587 | <h2>Dashboard</h2>
|
| 588 | <nav>
|
| 589 | <Link to="..">Dashboard Home</Link>
|
| 590 | <Link to="../team">Team</Link>
|
| 591 | <Link to="../projects">Projects</Link>
|
| 592 | </nav>
|
| 593 |
|
| 594 | <Routes>
|
| 595 | <Route path="/" element={<DashboardHome />} />
|
| 596 | <Route path="team" element={<DashboardTeam />} />
|
| 597 | <Route path="projects" element={<DashboardProjects />} />
|
| 598 | </Router>
|
| 599 | </div>
|
| 600 | );
|
| 601 | }
|
| 602 | ```
|
| 603 |
|
| 604 | 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".
|
| 605 |
|
| 606 | ### Patch Changes
|
| 607 |
|
| 608 | - Properly handle falsy error values in ErrorBoundary's ([#11071](https://github.com/remix-run/react-router/pull/11071))
|
| 609 | - Updated dependencies:
|
| 610 | - `@remix-run/router@1.14.0`
|
| 611 |
|
| 612 | ## 6.20.1
|
| 613 |
|
| 614 | ### Patch Changes
|
| 615 |
|
| 616 | - Revert the `useResolvedPath` fix for splat routes due to a large number of applications that were relying on the buggy behavior (see <https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329>). 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))
|
| 617 | - Updated dependencies:
|
| 618 | - `@remix-run/router@1.13.1`
|
| 619 |
|
| 620 | ## 6.20.0
|
| 621 |
|
| 622 | ### Minor Changes
|
| 623 |
|
| 624 | - Export the `PathParam` type from the public API ([#10719](https://github.com/remix-run/react-router/pull/10719))
|
| 625 |
|
| 626 | ### Patch Changes
|
| 627 |
|
| 628 | - Fix bug with `resolveTo` in splat routes ([#11045](https://github.com/remix-run/react-router/pull/11045))
|
| 629 | - 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`
|
| 630 | - This removes the `UNSAFE_getPathContributingMatches` export from `@remix-run/router` since we no longer need this in the `react-router`/`react-router-dom` layers
|
| 631 | - Updated dependencies:
|
| 632 | - `@remix-run/router@1.13.0`
|
| 633 |
|
| 634 | ## 6.19.0
|
| 635 |
|
| 636 | ### Minor Changes
|
| 637 |
|
| 638 | - 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))
|
| 639 | - Remove the `unstable_` prefix from the [`useBlocker`](https://reactrouter.com/v6/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))
|
| 640 |
|
| 641 | ### Patch Changes
|
| 642 |
|
| 643 | - 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))
|
| 644 |
|
| 645 | - 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))
|
| 646 |
|
| 647 | - ⚠️ 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.
|
| 648 |
|
| 649 | - Updated dependencies:
|
| 650 | - `@remix-run/router@1.12.0`
|
| 651 |
|
| 652 | ## 6.18.0
|
| 653 |
|
| 654 | ### Patch Changes
|
| 655 |
|
| 656 | - 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))
|
| 657 | - Updated dependencies:
|
| 658 | - `@remix-run/router@1.11.0`
|
| 659 |
|
| 660 | ## 6.17.0
|
| 661 |
|
| 662 | ### Patch Changes
|
| 663 |
|
| 664 | - 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))
|
| 665 | - Updated dependencies:
|
| 666 | - `@remix-run/router@1.10.0`
|
| 667 |
|
| 668 | ## 6.16.0
|
| 669 |
|
| 670 | ### Minor Changes
|
| 671 |
|
| 672 | - 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))
|
| 673 | - `Location` now accepts a generic for the `location.state` value
|
| 674 | - `ActionFunctionArgs`/`ActionFunction`/`LoaderFunctionArgs`/`LoaderFunction` now accept a generic for the `context` parameter (only used in SSR usages via `createStaticHandler`)
|
| 675 | - 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`
|
| 676 | - 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))
|
| 677 | - Export `ShouldRevalidateFunctionArgs` interface ([#10797](https://github.com/remix-run/react-router/pull/10797))
|
| 678 | - 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))
|
| 679 |
|
| 680 | ### Patch Changes
|
| 681 |
|
| 682 | - Updated dependencies:
|
| 683 | - `@remix-run/router@1.9.0`
|
| 684 |
|
| 685 | ## 6.15.0
|
| 686 |
|
| 687 | ### Minor Changes
|
| 688 |
|
| 689 | - 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))
|
| 690 |
|
| 691 | ### Patch Changes
|
| 692 |
|
| 693 | - Ensure `useRevalidator` is referentially stable across re-renders if revalidations are not actively occurring ([#10707](https://github.com/remix-run/react-router/pull/10707))
|
| 694 | - Updated dependencies:
|
| 695 | - `@remix-run/router@1.8.0`
|
| 696 |
|
| 697 | ## 6.14.2
|
| 698 |
|
| 699 | ### Patch Changes
|
| 700 |
|
| 701 | - Updated dependencies:
|
| 702 | - `@remix-run/router@1.7.2`
|
| 703 |
|
| 704 | ## 6.14.1
|
| 705 |
|
| 706 | ### Patch Changes
|
| 707 |
|
| 708 | - Fix loop in `unstable_useBlocker` when used with an unstable blocker function ([#10652](https://github.com/remix-run/react-router/pull/10652))
|
| 709 | - Fix issues with reused blockers on subsequent navigations ([#10656](https://github.com/remix-run/react-router/pull/10656))
|
| 710 | - Updated dependencies:
|
| 711 | - `@remix-run/router@1.7.1`
|
| 712 |
|
| 713 | ## 6.14.0
|
| 714 |
|
| 715 | ### Patch Changes
|
| 716 |
|
| 717 | - Strip `basename` from locations provided to `unstable_useBlocker` functions to match `useLocation` ([#10573](https://github.com/remix-run/react-router/pull/10573))
|
| 718 | - Fix `generatePath` when passed a numeric `0` value parameter ([#10612](https://github.com/remix-run/react-router/pull/10612))
|
| 719 | - Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573))
|
| 720 | - Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622))
|
| 721 | - Upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581))
|
| 722 | - Updated dependencies:
|
| 723 | - `@remix-run/router@1.7.0`
|
| 724 |
|
| 725 | ## 6.13.0
|
| 726 |
|
| 727 | ### Minor Changes
|
| 728 |
|
| 729 | - Move [`React.startTransition`](https://react.dev/reference/react/startTransition) usage behind a [future flag](https://reactrouter.com/v6/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))
|
| 730 |
|
| 731 | Existing behavior will no longer include `React.startTransition`:
|
| 732 |
|
| 733 | ```jsx
|
| 734 | <BrowserRouter>
|
| 735 | <Routes>{/*...*/}</Routes>
|
| 736 | </BrowserRouter>
|
| 737 |
|
| 738 | <RouterProvider router={router} />
|
| 739 | ```
|
| 740 |
|
| 741 | If you wish to enable `React.startTransition`, pass the future flag to your component:
|
| 742 |
|
| 743 | ```jsx
|
| 744 | <BrowserRouter future={{ v7_startTransition: true }}>
|
| 745 | <Routes>{/*...*/}</Routes>
|
| 746 | </BrowserRouter>
|
| 747 |
|
| 748 | <RouterProvider router={router} future={{ v7_startTransition: true }}/>
|
| 749 | ```
|
| 750 |
|
| 751 | ### Patch Changes
|
| 752 |
|
| 753 | - Work around webpack/terser `React.startTransition` minification bug in production mode ([#10588](https://github.com/remix-run/react-router/pull/10588))
|
| 754 |
|
| 755 | ## 6.12.1
|
| 756 |
|
| 757 | > \[!WARNING]
|
| 758 | > 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.
|
| 759 |
|
| 760 | ### Patch Changes
|
| 761 |
|
| 762 | - Adjust feature detection of `React.startTransition` to fix webpack + react 17 compilation error ([#10569](https://github.com/remix-run/react-router/pull/10569))
|
| 763 |
|
| 764 | ## 6.12.0
|
| 765 |
|
| 766 | ### Minor Changes
|
| 767 |
|
| 768 | - Wrap internal router state updates with `React.startTransition` if it exists ([#10438](https://github.com/remix-run/react-router/pull/10438))
|
| 769 |
|
| 770 | ### Patch Changes
|
| 771 |
|
| 772 | - Updated dependencies:
|
| 773 | - `@remix-run/router@1.6.3`
|
| 774 |
|
| 775 | ## 6.11.2
|
| 776 |
|
| 777 | ### Patch Changes
|
| 778 |
|
| 779 | - Fix `basename` duplication in descendant `<Routes>` inside a `<RouterProvider>` ([#10492](https://github.com/remix-run/react-router/pull/10492))
|
| 780 | - Updated dependencies:
|
| 781 | - `@remix-run/router@1.6.2`
|
| 782 |
|
| 783 | ## 6.11.1
|
| 784 |
|
| 785 | ### Patch Changes
|
| 786 |
|
| 787 | - Fix usage of `Component` API within descendant `<Routes>` ([#10434](https://github.com/remix-run/react-router/pull/10434))
|
| 788 | - Fix bug when calling `useNavigate` from `<Routes>` inside a `<RouterProvider>` ([#10432](https://github.com/remix-run/react-router/pull/10432))
|
| 789 | - Fix usage of `<Navigate>` in strict mode when using a data router ([#10435](https://github.com/remix-run/react-router/pull/10435))
|
| 790 | - Updated dependencies:
|
| 791 | - `@remix-run/router@1.6.1`
|
| 792 |
|
| 793 | ## 6.11.0
|
| 794 |
|
| 795 | ### Patch Changes
|
| 796 |
|
| 797 | - Log loader/action errors to the console in dev for easier stack trace evaluation ([#10286](https://github.com/remix-run/react-router/pull/10286))
|
| 798 | - Fix bug preventing rendering of descendant `<Routes>` when `RouterProvider` errors existed ([#10374](https://github.com/remix-run/react-router/pull/10374))
|
| 799 | - Fix inadvertent re-renders when using `Component` instead of `element` on a route definition ([#10287](https://github.com/remix-run/react-router/pull/10287))
|
| 800 | - 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))
|
| 801 | - 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))
|
| 802 | - Allow `useRevalidator()` to resolve a loader-driven error boundary scenario ([#10369](https://github.com/remix-run/react-router/pull/10369))
|
| 803 | - Avoid unnecessary unsubscribe/resubscribes on router state changes ([#10409](https://github.com/remix-run/react-router/pull/10409))
|
| 804 | - 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))
|
| 805 | - Updated dependencies:
|
| 806 | - `@remix-run/router@1.6.0`
|
| 807 |
|
| 808 | ## 6.10.0
|
| 809 |
|
| 810 | ### Minor Changes
|
| 811 |
|
| 812 | - Added support for [**Future Flags**](https://reactrouter.com/v6/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))
|
| 813 |
|
| 814 | - When `future.v7_normalizeFormMethod === false` (default v6 behavior),
|
| 815 | - `useNavigation().formMethod` is lowercase
|
| 816 | - `useFetcher().formMethod` is lowercase
|
| 817 | - When `future.v7_normalizeFormMethod === true`:
|
| 818 | - `useNavigation().formMethod` is uppercase
|
| 819 | - `useFetcher().formMethod` is uppercase
|
| 820 |
|
| 821 | ### Patch Changes
|
| 822 |
|
| 823 | - Fix route ID generation when using Fragments in `createRoutesFromElements` ([#10193](https://github.com/remix-run/react-router/pull/10193))
|
| 824 | - Updated dependencies:
|
| 825 | - `@remix-run/router@1.5.0`
|
| 826 |
|
| 827 | ## 6.9.0
|
| 828 |
|
| 829 | ### Minor Changes
|
| 830 |
|
| 831 | - 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))
|
| 832 |
|
| 833 | **Example JSON Syntax**
|
| 834 |
|
| 835 | ```jsx
|
| 836 | // Both of these work the same:
|
| 837 | const elementRoutes = [{
|
| 838 | path: '/',
|
| 839 | element: <Home />,
|
| 840 | errorElement: <HomeError />,
|
| 841 | }]
|
| 842 |
|
| 843 | const componentRoutes = [{
|
| 844 | path: '/',
|
| 845 | Component: Home,
|
| 846 | ErrorBoundary: HomeError,
|
| 847 | }]
|
| 848 |
|
| 849 | function Home() { ... }
|
| 850 | function HomeError() { ... }
|
| 851 | ```
|
| 852 |
|
| 853 | **Example JSX Syntax**
|
| 854 |
|
| 855 | ```jsx
|
| 856 | // Both of these work the same:
|
| 857 | const elementRoutes = createRoutesFromElements(
|
| 858 | <Route path='/' element={<Home />} errorElement={<HomeError /> } />
|
| 859 | );
|
| 860 |
|
| 861 | const componentRoutes = createRoutesFromElements(
|
| 862 | <Route path='/' Component={Home} ErrorBoundary={HomeError} />
|
| 863 | );
|
| 864 |
|
| 865 | function Home() { ... }
|
| 866 | function HomeError() { ... }
|
| 867 | ```
|
| 868 |
|
| 869 | - **Introducing Lazy Route Modules!** ([#10045](https://github.com/remix-run/react-router/pull/10045))
|
| 870 |
|
| 871 | 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`).
|
| 872 |
|
| 873 | 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.
|
| 874 |
|
| 875 | Your `lazy` functions will typically return the result of a dynamic import.
|
| 876 |
|
| 877 | ```jsx
|
| 878 | // In this example, we assume most folks land on the homepage so we include that
|
| 879 | // in our critical-path bundle, but then we lazily load modules for /a and /b so
|
| 880 | // they don't load until the user navigates to those routes
|
| 881 | let routes = createRoutesFromElements(
|
| 882 | <Route path="/" element={<Layout />}>
|
| 883 | <Route index element={<Home />} />
|
| 884 | <Route path="a" lazy={() => import("./a")} />
|
| 885 | <Route path="b" lazy={() => import("./b")} />
|
| 886 | </Route>
|
| 887 | );
|
| 888 | ```
|
| 889 |
|
| 890 | Then in your lazy route modules, export the properties you want defined for the route:
|
| 891 |
|
| 892 | ```jsx
|
| 893 | export async function loader({ request }) {
|
| 894 | let data = await fetchData(request);
|
| 895 | return json(data);
|
| 896 | }
|
| 897 |
|
| 898 | // Export a `Component` directly instead of needing to create a React Element from it
|
| 899 | export function Component() {
|
| 900 | let data = useLoaderData();
|
| 901 |
|
| 902 | return (
|
| 903 | <>
|
| 904 | <h1>You made it!</h1>
|
| 905 | <p>{data}</p>
|
| 906 | </>
|
| 907 | );
|
| 908 | }
|
| 909 |
|
| 910 | // Export an `ErrorBoundary` directly instead of needing to create a React Element from it
|
| 911 | export function ErrorBoundary() {
|
| 912 | let error = useRouteError();
|
| 913 | return isRouteErrorResponse(error) ? (
|
| 914 | <h1>
|
| 915 | {error.status} {error.statusText}
|
| 916 | </h1>
|
| 917 | ) : (
|
| 918 | <h1>{error.message || error}</h1>
|
| 919 | );
|
| 920 | }
|
| 921 | ```
|
| 922 |
|
| 923 | 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.
|
| 924 |
|
| 925 | 🙌 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).
|
| 926 |
|
| 927 | - Updated dependencies:
|
| 928 | - `@remix-run/router@1.4.0`
|
| 929 |
|
| 930 | ### Patch Changes
|
| 931 |
|
| 932 | - Fix `generatePath` incorrectly applying parameters in some cases ([#10078](https://github.com/remix-run/react-router/pull/10078))
|
| 933 | - Improve memoization for context providers to avoid unnecessary re-renders ([#9983](https://github.com/remix-run/react-router/pull/9983))
|
| 934 |
|
| 935 | ## 6.8.2
|
| 936 |
|
| 937 | ### Patch Changes
|
| 938 |
|
| 939 | - Updated dependencies:
|
| 940 | - `@remix-run/router@1.3.3`
|
| 941 |
|
| 942 | ## 6.8.1
|
| 943 |
|
| 944 | ### Patch Changes
|
| 945 |
|
| 946 | - Remove inaccurate console warning for POP navigations and update active blocker logic ([#10030](https://github.com/remix-run/react-router/pull/10030))
|
| 947 | - Updated dependencies:
|
| 948 | - `@remix-run/router@1.3.2`
|
| 949 |
|
| 950 | ## 6.8.0
|
| 951 |
|
| 952 | ### Patch Changes
|
| 953 |
|
| 954 | - Updated dependencies:
|
| 955 | - `@remix-run/router@1.3.1`
|
| 956 |
|
| 957 | ## 6.7.0
|
| 958 |
|
| 959 | ### Minor Changes
|
| 960 |
|
| 961 | - Add `unstable_useBlocker` hook for blocking navigations within the app's location origin ([#9709](https://github.com/remix-run/react-router/pull/9709))
|
| 962 |
|
| 963 | ### Patch Changes
|
| 964 |
|
| 965 | - Fix `generatePath` when optional params are present ([#9764](https://github.com/remix-run/react-router/pull/9764))
|
| 966 | - Update `<Await>` to accept `ReactNode` as children function return result ([#9896](https://github.com/remix-run/react-router/pull/9896))
|
| 967 | - Updated dependencies:
|
| 968 | - `@remix-run/router@1.3.0`
|
| 969 |
|
| 970 | ## 6.6.2
|
| 971 |
|
| 972 | ### Patch Changes
|
| 973 |
|
| 974 | - Ensure `useId` consistency during SSR ([#9805](https://github.com/remix-run/react-router/pull/9805))
|
| 975 |
|
| 976 | ## 6.6.1
|
| 977 |
|
| 978 | ### Patch Changes
|
| 979 |
|
| 980 | - Updated dependencies:
|
| 981 | - `@remix-run/router@1.2.1`
|
| 982 |
|
| 983 | ## 6.6.0
|
| 984 |
|
| 985 | ### Patch Changes
|
| 986 |
|
| 987 | - Prevent `useLoaderData` usage in `errorElement` ([#9735](https://github.com/remix-run/react-router/pull/9735))
|
| 988 | - Updated dependencies:
|
| 989 | - `@remix-run/router@1.2.0`
|
| 990 |
|
| 991 | ## 6.5.0
|
| 992 |
|
| 993 | 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.
|
| 994 |
|
| 995 | **Optional Params Examples**
|
| 996 |
|
| 997 | - `<Route path=":lang?/about>` will match:
|
| 998 | - `/:lang/about`
|
| 999 | - `/about`
|
| 1000 | - `<Route path="/multistep/:widget1?/widget2?/widget3?">` will match:
|
| 1001 | - `/multistep`
|
| 1002 | - `/multistep/:widget1`
|
| 1003 | - `/multistep/:widget1/:widget2`
|
| 1004 | - `/multistep/:widget1/:widget2/:widget3`
|
| 1005 |
|
| 1006 | **Optional Static Segment Example**
|
| 1007 |
|
| 1008 | - `<Route path="/home?">` will match:
|
| 1009 | - `/`
|
| 1010 | - `/home`
|
| 1011 | - `<Route path="/fr?/about">` will match:
|
| 1012 | - `/about`
|
| 1013 | - `/fr/about`
|
| 1014 |
|
| 1015 | ### Minor Changes
|
| 1016 |
|
| 1017 | - Allows optional routes and optional static segments ([#9650](https://github.com/remix-run/react-router/pull/9650))
|
| 1018 |
|
| 1019 | ### Patch Changes
|
| 1020 |
|
| 1021 | - 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))
|
| 1022 |
|
| 1023 | ```jsx
|
| 1024 | // Old behavior at URL /prefix-123
|
| 1025 | <Route path="prefix-:id" element={<Comp /> }>
|
| 1026 |
|
| 1027 | function Comp() {
|
| 1028 | let params = useParams(); // { id: '123' }
|
| 1029 | let id = params.id; // "123"
|
| 1030 | ...
|
| 1031 | }
|
| 1032 |
|
| 1033 | // New behavior at URL /prefix-123
|
| 1034 | <Route path=":id" element={<Comp /> }>
|
| 1035 |
|
| 1036 | function Comp() {
|
| 1037 | let params = useParams(); // { id: 'prefix-123' }
|
| 1038 | let id = params.id.replace(/^prefix-/, ''); // "123"
|
| 1039 | ...
|
| 1040 | }
|
| 1041 | ```
|
| 1042 |
|
| 1043 | - Updated dependencies:
|
| 1044 | - `@remix-run/router@1.1.0`
|
| 1045 |
|
| 1046 | ## 6.4.5
|
| 1047 |
|
| 1048 | ### Patch Changes
|
| 1049 |
|
| 1050 | - Updated dependencies:
|
| 1051 | - `@remix-run/router@1.0.5`
|
| 1052 |
|
| 1053 | ## 6.4.4
|
| 1054 |
|
| 1055 | ### Patch Changes
|
| 1056 |
|
| 1057 | - Updated dependencies:
|
| 1058 | - `@remix-run/router@1.0.4`
|
| 1059 |
|
| 1060 | ## 6.4.3
|
| 1061 |
|
| 1062 | ### Patch Changes
|
| 1063 |
|
| 1064 | - `useRoutes` should be able to return `null` when passing `locationArg` ([#9485](https://github.com/remix-run/react-router/pull/9485))
|
| 1065 | - fix `initialEntries` type in `createMemoryRouter` ([#9498](https://github.com/remix-run/react-router/pull/9498))
|
| 1066 | - Updated dependencies:
|
| 1067 | - `@remix-run/router@1.0.3`
|
| 1068 |
|
| 1069 | ## 6.4.2
|
| 1070 |
|
| 1071 | ### Patch Changes
|
| 1072 |
|
| 1073 | - Fix `IndexRouteObject` and `NonIndexRouteObject` types to make `hasErrorElement` optional ([#9394](https://github.com/remix-run/react-router/pull/9394))
|
| 1074 | - Enhance console error messages for invalid usage of data router hooks ([#9311](https://github.com/remix-run/react-router/pull/9311))
|
| 1075 | - 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))
|
| 1076 | - Updated dependencies:
|
| 1077 | - `@remix-run/router@1.0.2`
|
| 1078 |
|
| 1079 | ## 6.4.1
|
| 1080 |
|
| 1081 | ### Patch Changes
|
| 1082 |
|
| 1083 | - Preserve state from `initialEntries` ([#9288](https://github.com/remix-run/react-router/pull/9288))
|
| 1084 | - Updated dependencies:
|
| 1085 | - `@remix-run/router@1.0.1`
|
| 1086 |
|
| 1087 | ## 6.4.0
|
| 1088 |
|
| 1089 | 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/en/6.4.0/start/overview) and the [tutorial](https://reactrouter.com/en/6.4.0/start/tutorial).
|
| 1090 |
|
| 1091 | **New APIs**
|
| 1092 |
|
| 1093 | - Create your router with `createMemoryRouter`
|
| 1094 | - Render your router with `<RouterProvider>`
|
| 1095 | - Load data with a Route `loader` and mutate with a Route `action`
|
| 1096 | - Handle errors with Route `errorElement`
|
| 1097 | - Defer non-critical data with `defer` and `Await`
|
| 1098 |
|
| 1099 | **Bug Fixes**
|
| 1100 |
|
| 1101 | - Path resolution is now trailing slash agnostic (#8861)
|
| 1102 | - `useLocation` returns the scoped location inside a `<Routes location>` component (#9094)
|
| 1103 |
|
| 1104 | **Updated Dependencies**
|
| 1105 |
|
| 1106 | - `@remix-run/router@1.0.0`
|