[d565449] | 1 | # `react-router`
|
---|
| 2 |
|
---|
| 3 | ## 6.26.0
|
---|
| 4 |
|
---|
| 5 | ### Minor Changes
|
---|
| 6 |
|
---|
| 7 | - 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))
|
---|
| 8 |
|
---|
| 9 | ### Patch Changes
|
---|
| 10 |
|
---|
| 11 | - Fix initial hydration behavior when using `future.v7_partialHydration` along with `unstable_patchRoutesOnMiss` ([#11838](https://github.com/remix-run/react-router/pull/11838))
|
---|
| 12 | - During initial hydration, `router.state.matches` will now include any partial matches so that we can render ancestor `HydrateFallback` components
|
---|
| 13 | - Updated dependencies:
|
---|
| 14 | - `@remix-run/router@1.19.0`
|
---|
| 15 |
|
---|
| 16 | ## 6.25.1
|
---|
| 17 |
|
---|
| 18 | 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.
|
---|
| 19 |
|
---|
| 20 | ## 6.25.0
|
---|
| 21 |
|
---|
| 22 | ### Minor Changes
|
---|
| 23 |
|
---|
| 24 | - Stabilize `future.unstable_skipActionErrorRevalidation` as `future.v7_skipActionErrorRevalidation` ([#11769](https://github.com/remix-run/react-router/pull/11769))
|
---|
| 25 | - When this flag is enabled, actions will not automatically trigger a revalidation if they return/throw a `Response` with a `4xx`/`5xx` status code
|
---|
| 26 | - You may still opt-into revalidation via `shouldRevalidate`
|
---|
| 27 | - This also changes `shouldRevalidate`'s `unstable_actionStatus` parameter to `actionStatus`
|
---|
| 28 |
|
---|
| 29 | ### Patch Changes
|
---|
| 30 |
|
---|
| 31 | - Fix regression and properly decode paths inside `useMatch` so matches/params reflect decoded params ([#11789](https://github.com/remix-run/react-router/pull/11789))
|
---|
| 32 | - Updated dependencies:
|
---|
| 33 | - `@remix-run/router@1.18.0`
|
---|
| 34 |
|
---|
| 35 | ## 6.24.1
|
---|
| 36 |
|
---|
| 37 | ### Patch Changes
|
---|
| 38 |
|
---|
| 39 | - 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))
|
---|
| 40 | - Updated dependencies:
|
---|
| 41 | - `@remix-run/router@1.17.1`
|
---|
| 42 |
|
---|
| 43 | ## 6.24.0
|
---|
| 44 |
|
---|
| 45 | ### Minor Changes
|
---|
| 46 |
|
---|
| 47 | - Add support for Lazy Route Discovery (a.k.a. Fog of War) ([#11626](https://github.com/remix-run/react-router/pull/11626))
|
---|
| 48 | - RFC: <https://github.com/remix-run/react-router/discussions/11113>
|
---|
| 49 | - `unstable_patchRoutesOnMiss` docs: <https://reactrouter.com/en/main/routers/create-browser-router>
|
---|
| 50 |
|
---|
| 51 | ### Patch Changes
|
---|
| 52 |
|
---|
| 53 | - Updated dependencies:
|
---|
| 54 | - `@remix-run/router@1.17.0`
|
---|
| 55 |
|
---|
| 56 | ## 6.23.1
|
---|
| 57 |
|
---|
| 58 | ### Patch Changes
|
---|
| 59 |
|
---|
| 60 | - allow undefined to be resolved with `<Await>` ([#11513](https://github.com/remix-run/react-router/pull/11513))
|
---|
| 61 | - Updated dependencies:
|
---|
| 62 | - `@remix-run/router@1.16.1`
|
---|
| 63 |
|
---|
| 64 | ## 6.23.0
|
---|
| 65 |
|
---|
| 66 | ### Minor Changes
|
---|
| 67 |
|
---|
| 68 | - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098))
|
---|
| 69 | - This option allows Data Router applications to take control over the approach for executing route loaders and actions
|
---|
| 70 | - 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
|
---|
| 71 |
|
---|
| 72 | ### Patch Changes
|
---|
| 73 |
|
---|
| 74 | - Updated dependencies:
|
---|
| 75 | - `@remix-run/router@1.16.0`
|
---|
| 76 |
|
---|
| 77 | ## 6.22.3
|
---|
| 78 |
|
---|
| 79 | ### Patch Changes
|
---|
| 80 |
|
---|
| 81 | - Updated dependencies:
|
---|
| 82 | - `@remix-run/router@1.15.3`
|
---|
| 83 |
|
---|
| 84 | ## 6.22.2
|
---|
| 85 |
|
---|
| 86 | ### Patch Changes
|
---|
| 87 |
|
---|
| 88 | - Updated dependencies:
|
---|
| 89 | - `@remix-run/router@1.15.2`
|
---|
| 90 |
|
---|
| 91 | ## 6.22.1
|
---|
| 92 |
|
---|
| 93 | ### Patch Changes
|
---|
| 94 |
|
---|
| 95 | - Fix encoding/decoding issues with pre-encoded dynamic parameter values ([#11199](https://github.com/remix-run/react-router/pull/11199))
|
---|
| 96 | - Updated dependencies:
|
---|
| 97 | - `@remix-run/router@1.15.1`
|
---|
| 98 |
|
---|
| 99 | ## 6.22.0
|
---|
| 100 |
|
---|
| 101 | ### Patch Changes
|
---|
| 102 |
|
---|
| 103 | - Updated dependencies:
|
---|
| 104 | - `@remix-run/router@1.15.0`
|
---|
| 105 |
|
---|
| 106 | ## 6.21.3
|
---|
| 107 |
|
---|
| 108 | ### Patch Changes
|
---|
| 109 |
|
---|
| 110 | - Remove leftover `unstable_` prefix from `Blocker`/`BlockerFunction` types ([#11187](https://github.com/remix-run/react-router/pull/11187))
|
---|
| 111 |
|
---|
| 112 | ## 6.21.2
|
---|
| 113 |
|
---|
| 114 | ### Patch Changes
|
---|
| 115 |
|
---|
| 116 | - Updated dependencies:
|
---|
| 117 | - `@remix-run/router@1.14.2`
|
---|
| 118 |
|
---|
| 119 | ## 6.21.1
|
---|
| 120 |
|
---|
| 121 | ### Patch Changes
|
---|
| 122 |
|
---|
| 123 | - 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))
|
---|
| 124 | - Updated dependencies:
|
---|
| 125 | - `@remix-run/router@1.14.1`
|
---|
| 126 |
|
---|
| 127 | ## 6.21.0
|
---|
| 128 |
|
---|
| 129 | ### Minor Changes
|
---|
| 130 |
|
---|
| 131 | - 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))
|
---|
| 132 |
|
---|
| 133 | 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))
|
---|
| 134 |
|
---|
| 135 | **The Bug**
|
---|
| 136 | 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.
|
---|
| 137 |
|
---|
| 138 | **The Background**
|
---|
| 139 | 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:
|
---|
| 140 |
|
---|
| 141 | ```jsx
|
---|
| 142 | <BrowserRouter>
|
---|
| 143 | <Routes>
|
---|
| 144 | <Route path="/" element={<Home />} />
|
---|
| 145 | <Route path="dashboard/*" element={<Dashboard />} />
|
---|
| 146 | </Routes>
|
---|
| 147 | </BrowserRouter>
|
---|
| 148 | ```
|
---|
| 149 |
|
---|
| 150 | Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
|
---|
| 151 |
|
---|
| 152 | ```jsx
|
---|
| 153 | function Dashboard() {
|
---|
| 154 | return (
|
---|
| 155 | <div>
|
---|
| 156 | <h2>Dashboard</h2>
|
---|
| 157 | <nav>
|
---|
| 158 | <Link to="/">Dashboard Home</Link>
|
---|
| 159 | <Link to="team">Team</Link>
|
---|
| 160 | <Link to="projects">Projects</Link>
|
---|
| 161 | </nav>
|
---|
| 162 |
|
---|
| 163 | <Routes>
|
---|
| 164 | <Route path="/" element={<DashboardHome />} />
|
---|
| 165 | <Route path="team" element={<DashboardTeam />} />
|
---|
| 166 | <Route path="projects" element={<DashboardProjects />} />
|
---|
| 167 | </Routes>
|
---|
| 168 | </div>
|
---|
| 169 | );
|
---|
| 170 | }
|
---|
| 171 | ```
|
---|
| 172 |
|
---|
| 173 | 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.
|
---|
| 174 |
|
---|
| 175 | **The Problem**
|
---|
| 176 |
|
---|
| 177 | 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 `"."`:
|
---|
| 178 |
|
---|
| 179 | ```jsx
|
---|
| 180 | // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
|
---|
| 181 | function DashboardTeam() {
|
---|
| 182 | // ❌ This is broken and results in <a href="/dashboard">
|
---|
| 183 | return <Link to=".">A broken link to the Current URL</Link>;
|
---|
| 184 |
|
---|
| 185 | // ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
|
---|
| 186 | return <Link to="./team">A broken link to the Current URL</Link>;
|
---|
| 187 | }
|
---|
| 188 | ```
|
---|
| 189 |
|
---|
| 190 | 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.
|
---|
| 191 |
|
---|
| 192 | Even worse, consider a nested splat route configuration:
|
---|
| 193 |
|
---|
| 194 | ```jsx
|
---|
| 195 | <BrowserRouter>
|
---|
| 196 | <Routes>
|
---|
| 197 | <Route path="dashboard">
|
---|
| 198 | <Route path="*" element={<Dashboard />} />
|
---|
| 199 | </Route>
|
---|
| 200 | </Routes>
|
---|
| 201 | </BrowserRouter>
|
---|
| 202 | ```
|
---|
| 203 |
|
---|
| 204 | Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
|
---|
| 205 |
|
---|
| 206 | 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:
|
---|
| 207 |
|
---|
| 208 | ```jsx
|
---|
| 209 | let router = createBrowserRouter({
|
---|
| 210 | path: "/dashboard",
|
---|
| 211 | children: [
|
---|
| 212 | {
|
---|
| 213 | path: "*",
|
---|
| 214 | action: dashboardAction,
|
---|
| 215 | Component() {
|
---|
| 216 | // ❌ This form is broken! It throws a 405 error when it submits because
|
---|
| 217 | // it tries to submit to /dashboard (without the splat value) and the parent
|
---|
| 218 | // `/dashboard` route doesn't have an action
|
---|
| 219 | return <Form method="post">...</Form>;
|
---|
| 220 | },
|
---|
| 221 | },
|
---|
| 222 | ],
|
---|
| 223 | });
|
---|
| 224 | ```
|
---|
| 225 |
|
---|
| 226 | 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.
|
---|
| 227 |
|
---|
| 228 | **The Solution**
|
---|
| 229 | 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:
|
---|
| 230 |
|
---|
| 231 | ```jsx
|
---|
| 232 | <BrowserRouter>
|
---|
| 233 | <Routes>
|
---|
| 234 | <Route path="dashboard">
|
---|
| 235 | <Route index path="*" element={<Dashboard />} />
|
---|
| 236 | </Route>
|
---|
| 237 | </Routes>
|
---|
| 238 | </BrowserRouter>
|
---|
| 239 |
|
---|
| 240 | function Dashboard() {
|
---|
| 241 | return (
|
---|
| 242 | <div>
|
---|
| 243 | <h2>Dashboard</h2>
|
---|
| 244 | <nav>
|
---|
| 245 | <Link to="..">Dashboard Home</Link>
|
---|
| 246 | <Link to="../team">Team</Link>
|
---|
| 247 | <Link to="../projects">Projects</Link>
|
---|
| 248 | </nav>
|
---|
| 249 |
|
---|
| 250 | <Routes>
|
---|
| 251 | <Route path="/" element={<DashboardHome />} />
|
---|
| 252 | <Route path="team" element={<DashboardTeam />} />
|
---|
| 253 | <Route path="projects" element={<DashboardProjects />} />
|
---|
| 254 | </Router>
|
---|
| 255 | </div>
|
---|
| 256 | );
|
---|
| 257 | }
|
---|
| 258 | ```
|
---|
| 259 |
|
---|
| 260 | 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".
|
---|
| 261 |
|
---|
| 262 | ### Patch Changes
|
---|
| 263 |
|
---|
| 264 | - Properly handle falsy error values in ErrorBoundary's ([#11071](https://github.com/remix-run/react-router/pull/11071))
|
---|
| 265 | - Updated dependencies:
|
---|
| 266 | - `@remix-run/router@1.14.0`
|
---|
| 267 |
|
---|
| 268 | ## 6.20.1
|
---|
| 269 |
|
---|
| 270 | ### Patch Changes
|
---|
| 271 |
|
---|
| 272 | - 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))
|
---|
| 273 | - Updated dependencies:
|
---|
| 274 | - `@remix-run/router@1.13.1`
|
---|
| 275 |
|
---|
| 276 | ## 6.20.0
|
---|
| 277 |
|
---|
| 278 | ### Minor Changes
|
---|
| 279 |
|
---|
| 280 | - Export the `PathParam` type from the public API ([#10719](https://github.com/remix-run/react-router/pull/10719))
|
---|
| 281 |
|
---|
| 282 | ### Patch Changes
|
---|
| 283 |
|
---|
| 284 | - Fix bug with `resolveTo` in splat routes ([#11045](https://github.com/remix-run/react-router/pull/11045))
|
---|
| 285 | - 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`
|
---|
| 286 | - This removes the `UNSAFE_getPathContributingMatches` export from `@remix-run/router` since we no longer need this in the `react-router`/`react-router-dom` layers
|
---|
| 287 | - Updated dependencies:
|
---|
| 288 | - `@remix-run/router@1.13.0`
|
---|
| 289 |
|
---|
| 290 | ## 6.19.0
|
---|
| 291 |
|
---|
| 292 | ### Minor Changes
|
---|
| 293 |
|
---|
| 294 | - 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))
|
---|
| 295 | - 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))
|
---|
| 296 |
|
---|
| 297 | ### Patch Changes
|
---|
| 298 |
|
---|
| 299 | - 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))
|
---|
| 300 |
|
---|
| 301 | - 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))
|
---|
| 302 |
|
---|
| 303 | - ⚠️ 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.
|
---|
| 304 |
|
---|
| 305 | - Updated dependencies:
|
---|
| 306 | - `@remix-run/router@1.12.0`
|
---|
| 307 |
|
---|
| 308 | ## 6.18.0
|
---|
| 309 |
|
---|
| 310 | ### Patch Changes
|
---|
| 311 |
|
---|
| 312 | - 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))
|
---|
| 313 | - Updated dependencies:
|
---|
| 314 | - `@remix-run/router@1.11.0`
|
---|
| 315 |
|
---|
| 316 | ## 6.17.0
|
---|
| 317 |
|
---|
| 318 | ### Patch Changes
|
---|
| 319 |
|
---|
| 320 | - 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))
|
---|
| 321 | - Updated dependencies:
|
---|
| 322 | - `@remix-run/router@1.10.0`
|
---|
| 323 |
|
---|
| 324 | ## 6.16.0
|
---|
| 325 |
|
---|
| 326 | ### Minor Changes
|
---|
| 327 |
|
---|
| 328 | - 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))
|
---|
| 329 | - `Location` now accepts a generic for the `location.state` value
|
---|
| 330 | - `ActionFunctionArgs`/`ActionFunction`/`LoaderFunctionArgs`/`LoaderFunction` now accept a generic for the `context` parameter (only used in SSR usages via `createStaticHandler`)
|
---|
| 331 | - 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`
|
---|
| 332 | - 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))
|
---|
| 333 | - Export `ShouldRevalidateFunctionArgs` interface ([#10797](https://github.com/remix-run/react-router/pull/10797))
|
---|
| 334 | - 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))
|
---|
| 335 |
|
---|
| 336 | ### Patch Changes
|
---|
| 337 |
|
---|
| 338 | - Updated dependencies:
|
---|
| 339 | - `@remix-run/router@1.9.0`
|
---|
| 340 |
|
---|
| 341 | ## 6.15.0
|
---|
| 342 |
|
---|
| 343 | ### Minor Changes
|
---|
| 344 |
|
---|
| 345 | - 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))
|
---|
| 346 |
|
---|
| 347 | ### Patch Changes
|
---|
| 348 |
|
---|
| 349 | - Ensure `useRevalidator` is referentially stable across re-renders if revalidations are not actively occurring ([#10707](https://github.com/remix-run/react-router/pull/10707))
|
---|
| 350 | - Updated dependencies:
|
---|
| 351 | - `@remix-run/router@1.8.0`
|
---|
| 352 |
|
---|
| 353 | ## 6.14.2
|
---|
| 354 |
|
---|
| 355 | ### Patch Changes
|
---|
| 356 |
|
---|
| 357 | - Updated dependencies:
|
---|
| 358 | - `@remix-run/router@1.7.2`
|
---|
| 359 |
|
---|
| 360 | ## 6.14.1
|
---|
| 361 |
|
---|
| 362 | ### Patch Changes
|
---|
| 363 |
|
---|
| 364 | - Fix loop in `unstable_useBlocker` when used with an unstable blocker function ([#10652](https://github.com/remix-run/react-router/pull/10652))
|
---|
| 365 | - Fix issues with reused blockers on subsequent navigations ([#10656](https://github.com/remix-run/react-router/pull/10656))
|
---|
| 366 | - Updated dependencies:
|
---|
| 367 | - `@remix-run/router@1.7.1`
|
---|
| 368 |
|
---|
| 369 | ## 6.14.0
|
---|
| 370 |
|
---|
| 371 | ### Patch Changes
|
---|
| 372 |
|
---|
| 373 | - Strip `basename` from locations provided to `unstable_useBlocker` functions to match `useLocation` ([#10573](https://github.com/remix-run/react-router/pull/10573))
|
---|
| 374 | - Fix `generatePath` when passed a numeric `0` value parameter ([#10612](https://github.com/remix-run/react-router/pull/10612))
|
---|
| 375 | - Fix `unstable_useBlocker` key issues in `StrictMode` ([#10573](https://github.com/remix-run/react-router/pull/10573))
|
---|
| 376 | - Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622))
|
---|
| 377 | - Upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581))
|
---|
| 378 | - Updated dependencies:
|
---|
| 379 | - `@remix-run/router@1.7.0`
|
---|
| 380 |
|
---|
| 381 | ## 6.13.0
|
---|
| 382 |
|
---|
| 383 | ### Minor Changes
|
---|
| 384 |
|
---|
| 385 | - 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))
|
---|
| 386 |
|
---|
| 387 | Existing behavior will no longer include `React.startTransition`:
|
---|
| 388 |
|
---|
| 389 | ```jsx
|
---|
| 390 | <BrowserRouter>
|
---|
| 391 | <Routes>{/*...*/}</Routes>
|
---|
| 392 | </BrowserRouter>
|
---|
| 393 |
|
---|
| 394 | <RouterProvider router={router} />
|
---|
| 395 | ```
|
---|
| 396 |
|
---|
| 397 | If you wish to enable `React.startTransition`, pass the future flag to your component:
|
---|
| 398 |
|
---|
| 399 | ```jsx
|
---|
| 400 | <BrowserRouter future={{ v7_startTransition: true }}>
|
---|
| 401 | <Routes>{/*...*/}</Routes>
|
---|
| 402 | </BrowserRouter>
|
---|
| 403 |
|
---|
| 404 | <RouterProvider router={router} future={{ v7_startTransition: true }}/>
|
---|
| 405 | ```
|
---|
| 406 |
|
---|
| 407 | ### Patch Changes
|
---|
| 408 |
|
---|
| 409 | - Work around webpack/terser `React.startTransition` minification bug in production mode ([#10588](https://github.com/remix-run/react-router/pull/10588))
|
---|
| 410 |
|
---|
| 411 | ## 6.12.1
|
---|
| 412 |
|
---|
| 413 | > \[!WARNING]
|
---|
| 414 | > 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.
|
---|
| 415 |
|
---|
| 416 | ### Patch Changes
|
---|
| 417 |
|
---|
| 418 | - Adjust feature detection of `React.startTransition` to fix webpack + react 17 compilation error ([#10569](https://github.com/remix-run/react-router/pull/10569))
|
---|
| 419 |
|
---|
| 420 | ## 6.12.0
|
---|
| 421 |
|
---|
| 422 | ### Minor Changes
|
---|
| 423 |
|
---|
| 424 | - Wrap internal router state updates with `React.startTransition` if it exists ([#10438](https://github.com/remix-run/react-router/pull/10438))
|
---|
| 425 |
|
---|
| 426 | ### Patch Changes
|
---|
| 427 |
|
---|
| 428 | - Updated dependencies:
|
---|
| 429 | - `@remix-run/router@1.6.3`
|
---|
| 430 |
|
---|
| 431 | ## 6.11.2
|
---|
| 432 |
|
---|
| 433 | ### Patch Changes
|
---|
| 434 |
|
---|
| 435 | - Fix `basename` duplication in descendant `<Routes>` inside a `<RouterProvider>` ([#10492](https://github.com/remix-run/react-router/pull/10492))
|
---|
| 436 | - Updated dependencies:
|
---|
| 437 | - `@remix-run/router@1.6.2`
|
---|
| 438 |
|
---|
| 439 | ## 6.11.1
|
---|
| 440 |
|
---|
| 441 | ### Patch Changes
|
---|
| 442 |
|
---|
| 443 | - Fix usage of `Component` API within descendant `<Routes>` ([#10434](https://github.com/remix-run/react-router/pull/10434))
|
---|
| 444 | - Fix bug when calling `useNavigate` from `<Routes>` inside a `<RouterProvider>` ([#10432](https://github.com/remix-run/react-router/pull/10432))
|
---|
| 445 | - Fix usage of `<Navigate>` in strict mode when using a data router ([#10435](https://github.com/remix-run/react-router/pull/10435))
|
---|
| 446 | - Updated dependencies:
|
---|
| 447 | - `@remix-run/router@1.6.1`
|
---|
| 448 |
|
---|
| 449 | ## 6.11.0
|
---|
| 450 |
|
---|
| 451 | ### Patch Changes
|
---|
| 452 |
|
---|
| 453 | - Log loader/action errors to the console in dev for easier stack trace evaluation ([#10286](https://github.com/remix-run/react-router/pull/10286))
|
---|
| 454 | - Fix bug preventing rendering of descendant `<Routes>` when `RouterProvider` errors existed ([#10374](https://github.com/remix-run/react-router/pull/10374))
|
---|
| 455 | - Fix inadvertent re-renders when using `Component` instead of `element` on a route definition ([#10287](https://github.com/remix-run/react-router/pull/10287))
|
---|
| 456 | - 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))
|
---|
| 457 | - 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))
|
---|
| 458 | - Allow `useRevalidator()` to resolve a loader-driven error boundary scenario ([#10369](https://github.com/remix-run/react-router/pull/10369))
|
---|
| 459 | - Avoid unnecessary unsubscribe/resubscribes on router state changes ([#10409](https://github.com/remix-run/react-router/pull/10409))
|
---|
| 460 | - 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))
|
---|
| 461 | - Updated dependencies:
|
---|
| 462 | - `@remix-run/router@1.6.0`
|
---|
| 463 |
|
---|
| 464 | ## 6.10.0
|
---|
| 465 |
|
---|
| 466 | ### Minor Changes
|
---|
| 467 |
|
---|
| 468 | - 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))
|
---|
| 469 |
|
---|
| 470 | - When `future.v7_normalizeFormMethod === false` (default v6 behavior),
|
---|
| 471 | - `useNavigation().formMethod` is lowercase
|
---|
| 472 | - `useFetcher().formMethod` is lowercase
|
---|
| 473 | - When `future.v7_normalizeFormMethod === true`:
|
---|
| 474 | - `useNavigation().formMethod` is uppercase
|
---|
| 475 | - `useFetcher().formMethod` is uppercase
|
---|
| 476 |
|
---|
| 477 | ### Patch Changes
|
---|
| 478 |
|
---|
| 479 | - Fix route ID generation when using Fragments in `createRoutesFromElements` ([#10193](https://github.com/remix-run/react-router/pull/10193))
|
---|
| 480 | - Updated dependencies:
|
---|
| 481 | - `@remix-run/router@1.5.0`
|
---|
| 482 |
|
---|
| 483 | ## 6.9.0
|
---|
| 484 |
|
---|
| 485 | ### Minor Changes
|
---|
| 486 |
|
---|
| 487 | - 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))
|
---|
| 488 |
|
---|
| 489 | **Example JSON Syntax**
|
---|
| 490 |
|
---|
| 491 | ```jsx
|
---|
| 492 | // Both of these work the same:
|
---|
| 493 | const elementRoutes = [{
|
---|
| 494 | path: '/',
|
---|
| 495 | element: <Home />,
|
---|
| 496 | errorElement: <HomeError />,
|
---|
| 497 | }]
|
---|
| 498 |
|
---|
| 499 | const componentRoutes = [{
|
---|
| 500 | path: '/',
|
---|
| 501 | Component: Home,
|
---|
| 502 | ErrorBoundary: HomeError,
|
---|
| 503 | }]
|
---|
| 504 |
|
---|
| 505 | function Home() { ... }
|
---|
| 506 | function HomeError() { ... }
|
---|
| 507 | ```
|
---|
| 508 |
|
---|
| 509 | **Example JSX Syntax**
|
---|
| 510 |
|
---|
| 511 | ```jsx
|
---|
| 512 | // Both of these work the same:
|
---|
| 513 | const elementRoutes = createRoutesFromElements(
|
---|
| 514 | <Route path='/' element={<Home />} errorElement={<HomeError /> } />
|
---|
| 515 | );
|
---|
| 516 |
|
---|
| 517 | const componentRoutes = createRoutesFromElements(
|
---|
| 518 | <Route path='/' Component={Home} ErrorBoundary={HomeError} />
|
---|
| 519 | );
|
---|
| 520 |
|
---|
| 521 | function Home() { ... }
|
---|
| 522 | function HomeError() { ... }
|
---|
| 523 | ```
|
---|
| 524 |
|
---|
| 525 | - **Introducing Lazy Route Modules!** ([#10045](https://github.com/remix-run/react-router/pull/10045))
|
---|
| 526 |
|
---|
| 527 | 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`).
|
---|
| 528 |
|
---|
| 529 | 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.
|
---|
| 530 |
|
---|
| 531 | Your `lazy` functions will typically return the result of a dynamic import.
|
---|
| 532 |
|
---|
| 533 | ```jsx
|
---|
| 534 | // In this example, we assume most folks land on the homepage so we include that
|
---|
| 535 | // in our critical-path bundle, but then we lazily load modules for /a and /b so
|
---|
| 536 | // they don't load until the user navigates to those routes
|
---|
| 537 | let routes = createRoutesFromElements(
|
---|
| 538 | <Route path="/" element={<Layout />}>
|
---|
| 539 | <Route index element={<Home />} />
|
---|
| 540 | <Route path="a" lazy={() => import("./a")} />
|
---|
| 541 | <Route path="b" lazy={() => import("./b")} />
|
---|
| 542 | </Route>
|
---|
| 543 | );
|
---|
| 544 | ```
|
---|
| 545 |
|
---|
| 546 | Then in your lazy route modules, export the properties you want defined for the route:
|
---|
| 547 |
|
---|
| 548 | ```jsx
|
---|
| 549 | export async function loader({ request }) {
|
---|
| 550 | let data = await fetchData(request);
|
---|
| 551 | return json(data);
|
---|
| 552 | }
|
---|
| 553 |
|
---|
| 554 | // Export a `Component` directly instead of needing to create a React Element from it
|
---|
| 555 | export function Component() {
|
---|
| 556 | let data = useLoaderData();
|
---|
| 557 |
|
---|
| 558 | return (
|
---|
| 559 | <>
|
---|
| 560 | <h1>You made it!</h1>
|
---|
| 561 | <p>{data}</p>
|
---|
| 562 | </>
|
---|
| 563 | );
|
---|
| 564 | }
|
---|
| 565 |
|
---|
| 566 | // Export an `ErrorBoundary` directly instead of needing to create a React Element from it
|
---|
| 567 | export function ErrorBoundary() {
|
---|
| 568 | let error = useRouteError();
|
---|
| 569 | return isRouteErrorResponse(error) ? (
|
---|
| 570 | <h1>
|
---|
| 571 | {error.status} {error.statusText}
|
---|
| 572 | </h1>
|
---|
| 573 | ) : (
|
---|
| 574 | <h1>{error.message || error}</h1>
|
---|
| 575 | );
|
---|
| 576 | }
|
---|
| 577 | ```
|
---|
| 578 |
|
---|
| 579 | 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.
|
---|
| 580 |
|
---|
| 581 | 🙌 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).
|
---|
| 582 |
|
---|
| 583 | - Updated dependencies:
|
---|
| 584 | - `@remix-run/router@1.4.0`
|
---|
| 585 |
|
---|
| 586 | ### Patch Changes
|
---|
| 587 |
|
---|
| 588 | - Fix `generatePath` incorrectly applying parameters in some cases ([#10078](https://github.com/remix-run/react-router/pull/10078))
|
---|
| 589 | - Improve memoization for context providers to avoid unnecessary re-renders ([#9983](https://github.com/remix-run/react-router/pull/9983))
|
---|
| 590 |
|
---|
| 591 | ## 6.8.2
|
---|
| 592 |
|
---|
| 593 | ### Patch Changes
|
---|
| 594 |
|
---|
| 595 | - Updated dependencies:
|
---|
| 596 | - `@remix-run/router@1.3.3`
|
---|
| 597 |
|
---|
| 598 | ## 6.8.1
|
---|
| 599 |
|
---|
| 600 | ### Patch Changes
|
---|
| 601 |
|
---|
| 602 | - Remove inaccurate console warning for POP navigations and update active blocker logic ([#10030](https://github.com/remix-run/react-router/pull/10030))
|
---|
| 603 | - Updated dependencies:
|
---|
| 604 | - `@remix-run/router@1.3.2`
|
---|
| 605 |
|
---|
| 606 | ## 6.8.0
|
---|
| 607 |
|
---|
| 608 | ### Patch Changes
|
---|
| 609 |
|
---|
| 610 | - Updated dependencies:
|
---|
| 611 | - `@remix-run/router@1.3.1`
|
---|
| 612 |
|
---|
| 613 | ## 6.7.0
|
---|
| 614 |
|
---|
| 615 | ### Minor Changes
|
---|
| 616 |
|
---|
| 617 | - Add `unstable_useBlocker` hook for blocking navigations within the app's location origin ([#9709](https://github.com/remix-run/react-router/pull/9709))
|
---|
| 618 |
|
---|
| 619 | ### Patch Changes
|
---|
| 620 |
|
---|
| 621 | - Fix `generatePath` when optional params are present ([#9764](https://github.com/remix-run/react-router/pull/9764))
|
---|
| 622 | - Update `<Await>` to accept `ReactNode` as children function return result ([#9896](https://github.com/remix-run/react-router/pull/9896))
|
---|
| 623 | - Updated dependencies:
|
---|
| 624 | - `@remix-run/router@1.3.0`
|
---|
| 625 |
|
---|
| 626 | ## 6.6.2
|
---|
| 627 |
|
---|
| 628 | ### Patch Changes
|
---|
| 629 |
|
---|
| 630 | - Ensure `useId` consistency during SSR ([#9805](https://github.com/remix-run/react-router/pull/9805))
|
---|
| 631 |
|
---|
| 632 | ## 6.6.1
|
---|
| 633 |
|
---|
| 634 | ### Patch Changes
|
---|
| 635 |
|
---|
| 636 | - Updated dependencies:
|
---|
| 637 | - `@remix-run/router@1.2.1`
|
---|
| 638 |
|
---|
| 639 | ## 6.6.0
|
---|
| 640 |
|
---|
| 641 | ### Patch Changes
|
---|
| 642 |
|
---|
| 643 | - Prevent `useLoaderData` usage in `errorElement` ([#9735](https://github.com/remix-run/react-router/pull/9735))
|
---|
| 644 | - Updated dependencies:
|
---|
| 645 | - `@remix-run/router@1.2.0`
|
---|
| 646 |
|
---|
| 647 | ## 6.5.0
|
---|
| 648 |
|
---|
| 649 | 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.
|
---|
| 650 |
|
---|
| 651 | **Optional Params Examples**
|
---|
| 652 |
|
---|
| 653 | - `<Route path=":lang?/about>` will match:
|
---|
| 654 | - `/:lang/about`
|
---|
| 655 | - `/about`
|
---|
| 656 | - `<Route path="/multistep/:widget1?/widget2?/widget3?">` will match:
|
---|
| 657 | - `/multistep`
|
---|
| 658 | - `/multistep/:widget1`
|
---|
| 659 | - `/multistep/:widget1/:widget2`
|
---|
| 660 | - `/multistep/:widget1/:widget2/:widget3`
|
---|
| 661 |
|
---|
| 662 | **Optional Static Segment Example**
|
---|
| 663 |
|
---|
| 664 | - `<Route path="/home?">` will match:
|
---|
| 665 | - `/`
|
---|
| 666 | - `/home`
|
---|
| 667 | - `<Route path="/fr?/about">` will match:
|
---|
| 668 | - `/about`
|
---|
| 669 | - `/fr/about`
|
---|
| 670 |
|
---|
| 671 | ### Minor Changes
|
---|
| 672 |
|
---|
| 673 | - Allows optional routes and optional static segments ([#9650](https://github.com/remix-run/react-router/pull/9650))
|
---|
| 674 |
|
---|
| 675 | ### Patch Changes
|
---|
| 676 |
|
---|
| 677 | - 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))
|
---|
| 678 |
|
---|
| 679 | ```jsx
|
---|
| 680 | // Old behavior at URL /prefix-123
|
---|
| 681 | <Route path="prefix-:id" element={<Comp /> }>
|
---|
| 682 |
|
---|
| 683 | function Comp() {
|
---|
| 684 | let params = useParams(); // { id: '123' }
|
---|
| 685 | let id = params.id; // "123"
|
---|
| 686 | ...
|
---|
| 687 | }
|
---|
| 688 |
|
---|
| 689 | // New behavior at URL /prefix-123
|
---|
| 690 | <Route path=":id" element={<Comp /> }>
|
---|
| 691 |
|
---|
| 692 | function Comp() {
|
---|
| 693 | let params = useParams(); // { id: 'prefix-123' }
|
---|
| 694 | let id = params.id.replace(/^prefix-/, ''); // "123"
|
---|
| 695 | ...
|
---|
| 696 | }
|
---|
| 697 | ```
|
---|
| 698 |
|
---|
| 699 | - Updated dependencies:
|
---|
| 700 | - `@remix-run/router@1.1.0`
|
---|
| 701 |
|
---|
| 702 | ## 6.4.5
|
---|
| 703 |
|
---|
| 704 | ### Patch Changes
|
---|
| 705 |
|
---|
| 706 | - Updated dependencies:
|
---|
| 707 | - `@remix-run/router@1.0.5`
|
---|
| 708 |
|
---|
| 709 | ## 6.4.4
|
---|
| 710 |
|
---|
| 711 | ### Patch Changes
|
---|
| 712 |
|
---|
| 713 | - Updated dependencies:
|
---|
| 714 | - `@remix-run/router@1.0.4`
|
---|
| 715 |
|
---|
| 716 | ## 6.4.3
|
---|
| 717 |
|
---|
| 718 | ### Patch Changes
|
---|
| 719 |
|
---|
| 720 | - `useRoutes` should be able to return `null` when passing `locationArg` ([#9485](https://github.com/remix-run/react-router/pull/9485))
|
---|
| 721 | - fix `initialEntries` type in `createMemoryRouter` ([#9498](https://github.com/remix-run/react-router/pull/9498))
|
---|
| 722 | - Updated dependencies:
|
---|
| 723 | - `@remix-run/router@1.0.3`
|
---|
| 724 |
|
---|
| 725 | ## 6.4.2
|
---|
| 726 |
|
---|
| 727 | ### Patch Changes
|
---|
| 728 |
|
---|
| 729 | - Fix `IndexRouteObject` and `NonIndexRouteObject` types to make `hasErrorElement` optional ([#9394](https://github.com/remix-run/react-router/pull/9394))
|
---|
| 730 | - Enhance console error messages for invalid usage of data router hooks ([#9311](https://github.com/remix-run/react-router/pull/9311))
|
---|
| 731 | - 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))
|
---|
| 732 | - Updated dependencies:
|
---|
| 733 | - `@remix-run/router@1.0.2`
|
---|
| 734 |
|
---|
| 735 | ## 6.4.1
|
---|
| 736 |
|
---|
| 737 | ### Patch Changes
|
---|
| 738 |
|
---|
| 739 | - Preserve state from `initialEntries` ([#9288](https://github.com/remix-run/react-router/pull/9288))
|
---|
| 740 | - Updated dependencies:
|
---|
| 741 | - `@remix-run/router@1.0.1`
|
---|
| 742 |
|
---|
| 743 | ## 6.4.0
|
---|
| 744 |
|
---|
| 745 | 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).
|
---|
| 746 |
|
---|
| 747 | **New APIs**
|
---|
| 748 |
|
---|
| 749 | - Create your router with `createMemoryRouter`
|
---|
| 750 | - Render your router with `<RouterProvider>`
|
---|
| 751 | - Load data with a Route `loader` and mutate with a Route `action`
|
---|
| 752 | - Handle errors with Route `errorElement`
|
---|
| 753 | - Defer non-critical data with `defer` and `Await`
|
---|
| 754 |
|
---|
| 755 | **Bug Fixes**
|
---|
| 756 |
|
---|
| 757 | - Path resolution is now trailing slash agnostic (#8861)
|
---|
| 758 | - `useLocation` returns the scoped location inside a `<Routes location>` component (#9094)
|
---|
| 759 |
|
---|
| 760 | **Updated Dependencies**
|
---|
| 761 |
|
---|
| 762 | - `@remix-run/router@1.0.0`
|
---|