[d565449] | 1 | # `react-router-dom`
|
---|
| 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 | - `react-router@6.26.0`
|
---|
| 16 |
|
---|
| 17 | ## 6.25.1
|
---|
| 18 |
|
---|
| 19 | ### Patch Changes
|
---|
| 20 |
|
---|
| 21 | - Memoize some `RouterProvider` internals to reduce unnecessary re-renders ([#11803](https://github.com/remix-run/react-router/pull/11803))
|
---|
| 22 | - Updated dependencies:
|
---|
| 23 | - `react-router@6.25.1`
|
---|
| 24 |
|
---|
| 25 | ## 6.25.0
|
---|
| 26 |
|
---|
| 27 | ### Minor Changes
|
---|
| 28 |
|
---|
| 29 | - Stabilize `future.unstable_skipActionErrorRevalidation` as `future.v7_skipActionErrorRevalidation` ([#11769](https://github.com/remix-run/react-router/pull/11769))
|
---|
| 30 | - When this flag is enabled, actions will not automatically trigger a revalidation if they return/throw a `Response` with a `4xx`/`5xx` status code
|
---|
| 31 | - You may still opt-into revalidation via `shouldRevalidate`
|
---|
| 32 | - This also changes `shouldRevalidate`'s `unstable_actionStatus` parameter to `actionStatus`
|
---|
| 33 |
|
---|
| 34 | ### Patch Changes
|
---|
| 35 |
|
---|
| 36 | - Updated dependencies:
|
---|
| 37 | - `react-router@6.25.0`
|
---|
| 38 | - `@remix-run/router@1.18.0`
|
---|
| 39 |
|
---|
| 40 | ## 6.24.1
|
---|
| 41 |
|
---|
| 42 | ### Patch Changes
|
---|
| 43 |
|
---|
| 44 | - Remove `polyfill.io` reference from warning message because the domain was sold and has since been determined to serve malware ([#11741](https://github.com/remix-run/react-router/pull/11741))
|
---|
| 45 | - See <https://sansec.io/research/polyfill-supply-chain-attack>
|
---|
| 46 | - Export `NavLinkRenderProps` type for easier typing of custom `NavLink` callback ([#11553](https://github.com/remix-run/react-router/pull/11553))
|
---|
| 47 | - Updated dependencies:
|
---|
| 48 | - `@remix-run/router@1.17.1`
|
---|
| 49 | - `react-router@6.24.1`
|
---|
| 50 |
|
---|
| 51 | ## 6.24.0
|
---|
| 52 |
|
---|
| 53 | ### Minor Changes
|
---|
| 54 |
|
---|
| 55 | - Add support for Lazy Route Discovery (a.k.a. Fog of War) ([#11626](https://github.com/remix-run/react-router/pull/11626))
|
---|
| 56 | - RFC: <https://github.com/remix-run/react-router/discussions/11113>
|
---|
| 57 | - `unstable_patchRoutesOnMiss` docs: <https://reactrouter.com/en/main/routers/create-browser-router>
|
---|
| 58 |
|
---|
| 59 | ### Patch Changes
|
---|
| 60 |
|
---|
| 61 | - Fix `fetcher.submit` types - remove incorrect `navigate`/`fetcherKey`/`unstable_viewTransition` options because they are only relevant for `useSubmit` ([#11631](https://github.com/remix-run/react-router/pull/11631))
|
---|
| 62 | - Allow falsy `location.state` values passed to `<StaticRouter>` ([#11495](https://github.com/remix-run/react-router/pull/11495))
|
---|
| 63 | - Updated dependencies:
|
---|
| 64 | - `react-router@6.24.0`
|
---|
| 65 | - `@remix-run/router@1.17.0`
|
---|
| 66 |
|
---|
| 67 | ## 6.23.1
|
---|
| 68 |
|
---|
| 69 | ### Patch Changes
|
---|
| 70 |
|
---|
| 71 | - Check for `document` existence when checking `startViewTransition` ([#11544](https://github.com/remix-run/react-router/pull/11544))
|
---|
| 72 | - Change the `react-router-dom/server` import back to `react-router-dom` instead of `index.ts` ([#11514](https://github.com/remix-run/react-router/pull/11514))
|
---|
| 73 | - Updated dependencies:
|
---|
| 74 | - `@remix-run/router@1.16.1`
|
---|
| 75 | - `react-router@6.23.1`
|
---|
| 76 |
|
---|
| 77 | ## 6.23.0
|
---|
| 78 |
|
---|
| 79 | ### Minor Changes
|
---|
| 80 |
|
---|
| 81 | - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098))
|
---|
| 82 | - This option allows Data Router applications to take control over the approach for executing route loaders and actions
|
---|
| 83 | - 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
|
---|
| 84 |
|
---|
| 85 | ### Patch Changes
|
---|
| 86 |
|
---|
| 87 | - Updated dependencies:
|
---|
| 88 | - `@remix-run/router@1.16.0`
|
---|
| 89 | - `react-router@6.23.0`
|
---|
| 90 |
|
---|
| 91 | ## 6.22.3
|
---|
| 92 |
|
---|
| 93 | ### Patch Changes
|
---|
| 94 |
|
---|
| 95 | - Updated dependencies:
|
---|
| 96 | - `@remix-run/router@1.15.3`
|
---|
| 97 | - `react-router@6.22.3`
|
---|
| 98 |
|
---|
| 99 | ## 6.22.2
|
---|
| 100 |
|
---|
| 101 | ### Patch Changes
|
---|
| 102 |
|
---|
| 103 | - Updated dependencies:
|
---|
| 104 | - `@remix-run/router@1.15.2`
|
---|
| 105 | - `react-router@6.22.2`
|
---|
| 106 |
|
---|
| 107 | ## 6.22.1
|
---|
| 108 |
|
---|
| 109 | ### Patch Changes
|
---|
| 110 |
|
---|
| 111 | - Updated dependencies:
|
---|
| 112 | - `react-router@6.22.1`
|
---|
| 113 | - `@remix-run/router@1.15.1`
|
---|
| 114 |
|
---|
| 115 | ## 6.22.0
|
---|
| 116 |
|
---|
| 117 | ### Minor Changes
|
---|
| 118 |
|
---|
| 119 | - Include a `window__reactRouterVersion` tag for CWV Report detection ([#11222](https://github.com/remix-run/react-router/pull/11222))
|
---|
| 120 |
|
---|
| 121 | ### Patch Changes
|
---|
| 122 |
|
---|
| 123 | - Updated dependencies:
|
---|
| 124 | - `@remix-run/router@1.15.0`
|
---|
| 125 | - `react-router@6.22.0`
|
---|
| 126 |
|
---|
| 127 | ## 6.21.3
|
---|
| 128 |
|
---|
| 129 | ### Patch Changes
|
---|
| 130 |
|
---|
| 131 | - Fix `NavLink` `isPending` when a `basename` is used ([#11195](https://github.com/remix-run/react-router/pull/11195))
|
---|
| 132 | - Remove leftover `unstable_` prefix from `Blocker`/`BlockerFunction` types ([#11187](https://github.com/remix-run/react-router/pull/11187))
|
---|
| 133 | - Updated dependencies:
|
---|
| 134 | - `react-router@6.21.3`
|
---|
| 135 |
|
---|
| 136 | ## 6.21.2
|
---|
| 137 |
|
---|
| 138 | ### Patch Changes
|
---|
| 139 |
|
---|
| 140 | - Leverage `useId` for internal fetcher keys when available ([#11166](https://github.com/remix-run/react-router/pull/11166))
|
---|
| 141 | - Updated dependencies:
|
---|
| 142 | - `@remix-run/router@1.14.2`
|
---|
| 143 | - `react-router@6.21.2`
|
---|
| 144 |
|
---|
| 145 | ## 6.21.1
|
---|
| 146 |
|
---|
| 147 | ### Patch Changes
|
---|
| 148 |
|
---|
| 149 | - Updated dependencies:
|
---|
| 150 | - `react-router@6.21.1`
|
---|
| 151 | - `@remix-run/router@1.14.1`
|
---|
| 152 |
|
---|
| 153 | ## 6.21.0
|
---|
| 154 |
|
---|
| 155 | ### Minor Changes
|
---|
| 156 |
|
---|
| 157 | - 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))
|
---|
| 158 |
|
---|
| 159 | 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))
|
---|
| 160 |
|
---|
| 161 | **The Bug**
|
---|
| 162 | 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.
|
---|
| 163 |
|
---|
| 164 | **The Background**
|
---|
| 165 | 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:
|
---|
| 166 |
|
---|
| 167 | ```jsx
|
---|
| 168 | <BrowserRouter>
|
---|
| 169 | <Routes>
|
---|
| 170 | <Route path="/" element={<Home />} />
|
---|
| 171 | <Route path="dashboard/*" element={<Dashboard />} />
|
---|
| 172 | </Routes>
|
---|
| 173 | </BrowserRouter>
|
---|
| 174 | ```
|
---|
| 175 |
|
---|
| 176 | Any paths like `/dashboard`, `/dashboard/team`, `/dashboard/projects` will match the `Dashboard` route. The dashboard component itself can then render nested `<Routes>`:
|
---|
| 177 |
|
---|
| 178 | ```jsx
|
---|
| 179 | function Dashboard() {
|
---|
| 180 | return (
|
---|
| 181 | <div>
|
---|
| 182 | <h2>Dashboard</h2>
|
---|
| 183 | <nav>
|
---|
| 184 | <Link to="/">Dashboard Home</Link>
|
---|
| 185 | <Link to="team">Team</Link>
|
---|
| 186 | <Link to="projects">Projects</Link>
|
---|
| 187 | </nav>
|
---|
| 188 |
|
---|
| 189 | <Routes>
|
---|
| 190 | <Route path="/" element={<DashboardHome />} />
|
---|
| 191 | <Route path="team" element={<DashboardTeam />} />
|
---|
| 192 | <Route path="projects" element={<DashboardProjects />} />
|
---|
| 193 | </Routes>
|
---|
| 194 | </div>
|
---|
| 195 | );
|
---|
| 196 | }
|
---|
| 197 | ```
|
---|
| 198 |
|
---|
| 199 | 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.
|
---|
| 200 |
|
---|
| 201 | **The Problem**
|
---|
| 202 |
|
---|
| 203 | 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 `"."`:
|
---|
| 204 |
|
---|
| 205 | ```jsx
|
---|
| 206 | // If we are on URL /dashboard/team, and we want to link to /dashboard/team:
|
---|
| 207 | function DashboardTeam() {
|
---|
| 208 | // ❌ This is broken and results in <a href="/dashboard">
|
---|
| 209 | return <Link to=".">A broken link to the Current URL</Link>;
|
---|
| 210 |
|
---|
| 211 | // ✅ This is fixed but super unintuitive since we're already at /dashboard/team!
|
---|
| 212 | return <Link to="./team">A broken link to the Current URL</Link>;
|
---|
| 213 | }
|
---|
| 214 | ```
|
---|
| 215 |
|
---|
| 216 | 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.
|
---|
| 217 |
|
---|
| 218 | Even worse, consider a nested splat route configuration:
|
---|
| 219 |
|
---|
| 220 | ```jsx
|
---|
| 221 | <BrowserRouter>
|
---|
| 222 | <Routes>
|
---|
| 223 | <Route path="dashboard">
|
---|
| 224 | <Route path="*" element={<Dashboard />} />
|
---|
| 225 | </Route>
|
---|
| 226 | </Routes>
|
---|
| 227 | </BrowserRouter>
|
---|
| 228 | ```
|
---|
| 229 |
|
---|
| 230 | Now, a `<Link to=".">` and a `<Link to="..">` inside the `Dashboard` component go to the same place! That is definitely not correct!
|
---|
| 231 |
|
---|
| 232 | 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:
|
---|
| 233 |
|
---|
| 234 | ```jsx
|
---|
| 235 | let router = createBrowserRouter({
|
---|
| 236 | path: "/dashboard",
|
---|
| 237 | children: [
|
---|
| 238 | {
|
---|
| 239 | path: "*",
|
---|
| 240 | action: dashboardAction,
|
---|
| 241 | Component() {
|
---|
| 242 | // ❌ This form is broken! It throws a 405 error when it submits because
|
---|
| 243 | // it tries to submit to /dashboard (without the splat value) and the parent
|
---|
| 244 | // `/dashboard` route doesn't have an action
|
---|
| 245 | return <Form method="post">...</Form>;
|
---|
| 246 | },
|
---|
| 247 | },
|
---|
| 248 | ],
|
---|
| 249 | });
|
---|
| 250 | ```
|
---|
| 251 |
|
---|
| 252 | 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.
|
---|
| 253 |
|
---|
| 254 | **The Solution**
|
---|
| 255 | 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:
|
---|
| 256 |
|
---|
| 257 | ```jsx
|
---|
| 258 | <BrowserRouter>
|
---|
| 259 | <Routes>
|
---|
| 260 | <Route path="dashboard">
|
---|
| 261 | <Route index path="*" element={<Dashboard />} />
|
---|
| 262 | </Route>
|
---|
| 263 | </Routes>
|
---|
| 264 | </BrowserRouter>
|
---|
| 265 |
|
---|
| 266 | function Dashboard() {
|
---|
| 267 | return (
|
---|
| 268 | <div>
|
---|
| 269 | <h2>Dashboard</h2>
|
---|
| 270 | <nav>
|
---|
| 271 | <Link to="..">Dashboard Home</Link>
|
---|
| 272 | <Link to="../team">Team</Link>
|
---|
| 273 | <Link to="../projects">Projects</Link>
|
---|
| 274 | </nav>
|
---|
| 275 |
|
---|
| 276 | <Routes>
|
---|
| 277 | <Route path="/" element={<DashboardHome />} />
|
---|
| 278 | <Route path="team" element={<DashboardTeam />} />
|
---|
| 279 | <Route path="projects" element={<DashboardProjects />} />
|
---|
| 280 | </Router>
|
---|
| 281 | </div>
|
---|
| 282 | );
|
---|
| 283 | }
|
---|
| 284 | ```
|
---|
| 285 |
|
---|
| 286 | 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".
|
---|
| 287 |
|
---|
| 288 | ### Patch Changes
|
---|
| 289 |
|
---|
| 290 | - Updated dependencies:
|
---|
| 291 | - `@remix-run/router@1.14.0`
|
---|
| 292 | - `react-router@6.21.0`
|
---|
| 293 |
|
---|
| 294 | ## 6.20.1
|
---|
| 295 |
|
---|
| 296 | ### Patch Changes
|
---|
| 297 |
|
---|
| 298 | - 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))
|
---|
| 299 | - Updated dependencies:
|
---|
| 300 | - `react-router@6.20.1`
|
---|
| 301 | - `@remix-run/router@1.13.1`
|
---|
| 302 |
|
---|
| 303 | ## 6.20.0
|
---|
| 304 |
|
---|
| 305 | ### Minor Changes
|
---|
| 306 |
|
---|
| 307 | - Export the `PathParam` type from the public API ([#10719](https://github.com/remix-run/react-router/pull/10719))
|
---|
| 308 |
|
---|
| 309 | ### Patch Changes
|
---|
| 310 |
|
---|
| 311 | - Updated dependencies:
|
---|
| 312 | - `react-router@6.20.0`
|
---|
| 313 | - `@remix-run/router@1.13.0`
|
---|
| 314 |
|
---|
| 315 | ## 6.19.0
|
---|
| 316 |
|
---|
| 317 | ### Minor Changes
|
---|
| 318 |
|
---|
| 319 | - 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))
|
---|
| 320 | - Allow `unstable_usePrompt` to accept a `BlockerFunction` in addition to a `boolean` ([#10991](https://github.com/remix-run/react-router/pull/10991))
|
---|
| 321 |
|
---|
| 322 | ### Patch Changes
|
---|
| 323 |
|
---|
| 324 | - Fix issue where a changing fetcher `key` in a `useFetcher` that remains mounted wasn't getting picked up ([#11009](https://github.com/remix-run/react-router/pull/11009))
|
---|
| 325 | - Fix `useFormAction` which was incorrectly inheriting the `?index` query param from child route `action` submissions ([#11025](https://github.com/remix-run/react-router/pull/11025))
|
---|
| 326 | - Fix `NavLink` `active` logic when `to` location has a trailing slash ([#10734](https://github.com/remix-run/react-router/pull/10734))
|
---|
| 327 | - Updated dependencies:
|
---|
| 328 | - `react-router@6.19.0`
|
---|
| 329 | - `@remix-run/router@1.12.0`
|
---|
| 330 |
|
---|
| 331 | ## 6.18.0
|
---|
| 332 |
|
---|
| 333 | ### Minor Changes
|
---|
| 334 |
|
---|
| 335 | - Add support for manual fetcher key specification via `useFetcher({ key: string })` so you can access the same fetcher instance from different components in your application without prop-drilling ([RFC](https://github.com/remix-run/remix/discussions/7698)) ([#10960](https://github.com/remix-run/react-router/pull/10960))
|
---|
| 336 |
|
---|
| 337 | - Fetcher keys are now also exposed on the fetchers returned from `useFetchers` so that they can be looked up by `key`
|
---|
| 338 |
|
---|
| 339 | - Add `navigate`/`fetcherKey` params/props to `useSumbit`/`Form` to support kicking off a fetcher submission under the hood with an optionally user-specified `key` ([#10960](https://github.com/remix-run/react-router/pull/10960))
|
---|
| 340 |
|
---|
| 341 | - Invoking a fetcher in this way is ephemeral and stateless
|
---|
| 342 | - If you need to access the state of one of these fetchers, you will need to leverage `useFetcher({ key })` to look it up elsewhere
|
---|
| 343 |
|
---|
| 344 | ### Patch Changes
|
---|
| 345 |
|
---|
| 346 | - Adds a fetcher context to `RouterProvider` that holds completed fetcher data, in preparation for the upcoming future flag that will change the fetcher persistence/cleanup behavior ([#10961](https://github.com/remix-run/react-router/pull/10961))
|
---|
| 347 | - 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))
|
---|
| 348 | - Updated dependencies:
|
---|
| 349 | - `@remix-run/router@1.11.0`
|
---|
| 350 | - `react-router@6.18.0`
|
---|
| 351 |
|
---|
| 352 | ## 6.17.0
|
---|
| 353 |
|
---|
| 354 | ### Minor Changes
|
---|
| 355 |
|
---|
| 356 | - Add experimental support for the [View Transitions API](https://developer.mozilla.org/en-US/docs/Web/API/ViewTransition) via `document.startViewTransition` to enable CSS animated transitions on SPA navigations in your application. ([#10916](https://github.com/remix-run/react-router/pull/10916))
|
---|
| 357 |
|
---|
| 358 | The simplest approach to enabling a View Transition in your React Router app is via the new `<Link unstable_viewTransition>` prop. This will cause the navigation DOM update to be wrapped in `document.startViewTransition` which will enable transitions for the DOM update. Without any additional CSS styles, you'll get a basic cross-fade animation for your page.
|
---|
| 359 |
|
---|
| 360 | If you need to apply more fine-grained styles for your animations, you can leverage the `unstable_useViewTransitionState` hook which will tell you when a transition is in progress and you can use that to apply classes or styles:
|
---|
| 361 |
|
---|
| 362 | ```jsx
|
---|
| 363 | function ImageLink(to, src, alt) {
|
---|
| 364 | let isTransitioning = unstable_useViewTransitionState(to);
|
---|
| 365 | return (
|
---|
| 366 | <Link to={to} unstable_viewTransition>
|
---|
| 367 | <img
|
---|
| 368 | src={src}
|
---|
| 369 | alt={alt}
|
---|
| 370 | style={{
|
---|
| 371 | viewTransitionName: isTransitioning ? "image-expand" : "",
|
---|
| 372 | }}
|
---|
| 373 | />
|
---|
| 374 | </Link>
|
---|
| 375 | );
|
---|
| 376 | }
|
---|
| 377 | ```
|
---|
| 378 |
|
---|
| 379 | You can also use the `<NavLink unstable_viewTransition>` shorthand which will manage the hook usage for you and automatically add a `transitioning` class to the `<a>` during the transition:
|
---|
| 380 |
|
---|
| 381 | ```css
|
---|
| 382 | a.transitioning img {
|
---|
| 383 | view-transition-name: "image-expand";
|
---|
| 384 | }
|
---|
| 385 | ```
|
---|
| 386 |
|
---|
| 387 | ```jsx
|
---|
| 388 | <NavLink to={to} unstable_viewTransition>
|
---|
| 389 | <img src={src} alt={alt} />
|
---|
| 390 | </NavLink>
|
---|
| 391 | ```
|
---|
| 392 |
|
---|
| 393 | For an example usage of View Transitions with React Router, check out [our fork](https://github.com/brophdawg11/react-router-records) of the [Astro Records](https://github.com/Charca/astro-records) demo.
|
---|
| 394 |
|
---|
| 395 | For more information on using the View Transitions API, please refer to the [Smooth and simple transitions with the View Transitions API](https://developer.chrome.com/docs/web-platform/view-transitions/) guide from the Google Chrome team.
|
---|
| 396 |
|
---|
| 397 | Please note, that because the `ViewTransition` API is a DOM API, we now export a specific `RouterProvider` from `react-router-dom` with this functionality. If you are importing `RouterProvider` from `react-router`, then it will not support view transitions. ([#10928](https://github.com/remix-run/react-router/pull/10928)
|
---|
| 398 |
|
---|
| 399 | ### Patch Changes
|
---|
| 400 |
|
---|
| 401 | - Log a warning and fail gracefully in `ScrollRestoration` when `sessionStorage` is unavailable ([#10848](https://github.com/remix-run/react-router/pull/10848))
|
---|
| 402 | - Updated dependencies:
|
---|
| 403 | - `@remix-run/router@1.10.0`
|
---|
| 404 | - `react-router@6.17.0`
|
---|
| 405 |
|
---|
| 406 | ## 6.16.0
|
---|
| 407 |
|
---|
| 408 | ### Minor Changes
|
---|
| 409 |
|
---|
| 410 | - Updated dependencies:
|
---|
| 411 | - `@remix-run/router@1.9.0`
|
---|
| 412 | - `react-router@6.16.0`
|
---|
| 413 |
|
---|
| 414 | ### Patch Changes
|
---|
| 415 |
|
---|
| 416 | - Properly encode rendered URIs in server rendering to avoid hydration errors ([#10769](https://github.com/remix-run/react-router/pull/10769))
|
---|
| 417 |
|
---|
| 418 | ## 6.15.0
|
---|
| 419 |
|
---|
| 420 | ### Minor Changes
|
---|
| 421 |
|
---|
| 422 | - 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))
|
---|
| 423 |
|
---|
| 424 | ### Patch Changes
|
---|
| 425 |
|
---|
| 426 | - Fixes an edge-case affecting web extensions in Firefox that use `URLSearchParams` and the `useSearchParams` hook. ([#10620](https://github.com/remix-run/react-router/pull/10620))
|
---|
| 427 | - Do not include hash in `useFormAction()` for unspecified actions since it cannot be determined on the server and causes hydration issues ([#10758](https://github.com/remix-run/react-router/pull/10758))
|
---|
| 428 | - Reorder effects in `unstable_usePrompt` to avoid throwing an exception if the prompt is unblocked and a navigation is performed synchronously ([#10687](https://github.com/remix-run/react-router/pull/10687), [#10718](https://github.com/remix-run/react-router/pull/10718))
|
---|
| 429 | - Updated dependencies:
|
---|
| 430 | - `@remix-run/router@1.8.0`
|
---|
| 431 | - `react-router@6.15.0`
|
---|
| 432 |
|
---|
| 433 | ## 6.14.2
|
---|
| 434 |
|
---|
| 435 | ### Patch Changes
|
---|
| 436 |
|
---|
| 437 | - Properly decode element id when emulating hash scrolling via `<ScrollRestoration>` ([#10682](https://github.com/remix-run/react-router/pull/10682))
|
---|
| 438 | - Add missing `<Form state>` prop to populate `history.state` on submission navigations ([#10630](https://github.com/remix-run/react-router/pull/10630))
|
---|
| 439 | - Support proper hydration of `Error` subclasses such as `ReferenceError`/`TypeError` ([#10633](https://github.com/remix-run/react-router/pull/10633))
|
---|
| 440 | - Updated dependencies:
|
---|
| 441 | - `@remix-run/router@1.7.2`
|
---|
| 442 | - `react-router@6.14.2`
|
---|
| 443 |
|
---|
| 444 | ## 6.14.1
|
---|
| 445 |
|
---|
| 446 | ### Patch Changes
|
---|
| 447 |
|
---|
| 448 | - Updated dependencies:
|
---|
| 449 | - `react-router@6.14.1`
|
---|
| 450 | - `@remix-run/router@1.7.1`
|
---|
| 451 |
|
---|
| 452 | ## 6.14.0
|
---|
| 453 |
|
---|
| 454 | ### Minor Changes
|
---|
| 455 |
|
---|
| 456 | - Add support for `application/json` and `text/plain` encodings for `useSubmit`/`fetcher.submit`. To reflect these additional types, `useNavigation`/`useFetcher` now also contain `navigation.json`/`navigation.text` and `fetcher.json`/`fetcher.text` which include the json/text submission if applicable ([#10413](https://github.com/remix-run/react-router/pull/10413))
|
---|
| 457 |
|
---|
| 458 | ```jsx
|
---|
| 459 | // The default behavior will still serialize as FormData
|
---|
| 460 | function Component() {
|
---|
| 461 | let navigation = useNavigation();
|
---|
| 462 | let submit = useSubmit();
|
---|
| 463 | submit({ key: "value" }, { method: "post" });
|
---|
| 464 | // navigation.formEncType => "application/x-www-form-urlencoded"
|
---|
| 465 | // navigation.formData => FormData instance
|
---|
| 466 | }
|
---|
| 467 |
|
---|
| 468 | async function action({ request }) {
|
---|
| 469 | // request.headers.get("Content-Type") => "application/x-www-form-urlencoded"
|
---|
| 470 | // await request.formData() => FormData instance
|
---|
| 471 | }
|
---|
| 472 | ```
|
---|
| 473 |
|
---|
| 474 | ```js
|
---|
| 475 | // Opt-into JSON encoding with `encType: "application/json"`
|
---|
| 476 | function Component() {
|
---|
| 477 | let navigation = useNavigation();
|
---|
| 478 | let submit = useSubmit();
|
---|
| 479 | submit({ key: "value" }, { method: "post", encType: "application/json" });
|
---|
| 480 | // navigation.formEncType => "application/json"
|
---|
| 481 | // navigation.json => { key: "value" }
|
---|
| 482 | }
|
---|
| 483 |
|
---|
| 484 | async function action({ request }) {
|
---|
| 485 | // request.headers.get("Content-Type") => "application/json"
|
---|
| 486 | // await request.json() => { key: "value" }
|
---|
| 487 | }
|
---|
| 488 | ```
|
---|
| 489 |
|
---|
| 490 | ```js
|
---|
| 491 | // Opt-into text encoding with `encType: "text/plain"`
|
---|
| 492 | function Component() {
|
---|
| 493 | let navigation = useNavigation();
|
---|
| 494 | let submit = useSubmit();
|
---|
| 495 | submit("Text submission", { method: "post", encType: "text/plain" });
|
---|
| 496 | // navigation.formEncType => "text/plain"
|
---|
| 497 | // navigation.text => "Text submission"
|
---|
| 498 | }
|
---|
| 499 |
|
---|
| 500 | async function action({ request }) {
|
---|
| 501 | // request.headers.get("Content-Type") => "text/plain"
|
---|
| 502 | // await request.text() => "Text submission"
|
---|
| 503 | }
|
---|
| 504 | ```
|
---|
| 505 |
|
---|
| 506 | ### Patch Changes
|
---|
| 507 |
|
---|
| 508 | - When submitting a form from a `submitter` element, prefer the built-in `new FormData(form, submitter)` instead of the previous manual approach in modern browsers (those that support the new `submitter` parameter) ([#9865](https://github.com/remix-run/react-router/pull/9865), [#10627](https://github.com/remix-run/react-router/pull/10627))
|
---|
| 509 | - For browsers that don't support it, we continue to just append the submit button's entry to the end, and we also add rudimentary support for `type="image"` buttons
|
---|
| 510 | - If developers want full spec-compliant support for legacy browsers, they can use the `formdata-submitter-polyfill`
|
---|
| 511 | - Call `window.history.pushState/replaceState` before updating React Router state (instead of after) so that `window.location` matches `useLocation` during synchronous React 17 rendering ([#10448](https://github.com/remix-run/react-router/pull/10448))
|
---|
| 512 | - ⚠️ However, generally apps should not be relying on `window.location` and should always reference `useLocation` when possible, as `window.location` will not be in sync 100% of the time (due to `popstate` events, concurrent mode, etc.)
|
---|
| 513 | - Fix `tsc --skipLibCheck:false` issues on React 17 ([#10622](https://github.com/remix-run/react-router/pull/10622))
|
---|
| 514 | - Upgrade `typescript` to 5.1 ([#10581](https://github.com/remix-run/react-router/pull/10581))
|
---|
| 515 | - Updated dependencies:
|
---|
| 516 | - `react-router@6.14.0`
|
---|
| 517 | - `@remix-run/router@1.7.0`
|
---|
| 518 |
|
---|
| 519 | ## 6.13.0
|
---|
| 520 |
|
---|
| 521 | ### Minor Changes
|
---|
| 522 |
|
---|
| 523 | - 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))
|
---|
| 524 |
|
---|
| 525 | Existing behavior will no longer include `React.startTransition`:
|
---|
| 526 |
|
---|
| 527 | ```jsx
|
---|
| 528 | <BrowserRouter>
|
---|
| 529 | <Routes>{/*...*/}</Routes>
|
---|
| 530 | </BrowserRouter>
|
---|
| 531 |
|
---|
| 532 | <RouterProvider router={router} />
|
---|
| 533 | ```
|
---|
| 534 |
|
---|
| 535 | If you wish to enable `React.startTransition`, pass the future flag to your component:
|
---|
| 536 |
|
---|
| 537 | ```jsx
|
---|
| 538 | <BrowserRouter future={{ v7_startTransition: true }}>
|
---|
| 539 | <Routes>{/*...*/}</Routes>
|
---|
| 540 | </BrowserRouter>
|
---|
| 541 |
|
---|
| 542 | <RouterProvider router={router} future={{ v7_startTransition: true }}/>
|
---|
| 543 | ```
|
---|
| 544 |
|
---|
| 545 | ### Patch Changes
|
---|
| 546 |
|
---|
| 547 | - Work around webpack/terser `React.startTransition` minification bug in production mode ([#10588](https://github.com/remix-run/react-router/pull/10588))
|
---|
| 548 | - Updated dependencies:
|
---|
| 549 | - `react-router@6.13.0`
|
---|
| 550 |
|
---|
| 551 | ## 6.12.1
|
---|
| 552 |
|
---|
| 553 | > \[!WARNING]
|
---|
| 554 | > 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.
|
---|
| 555 |
|
---|
| 556 | ### Patch Changes
|
---|
| 557 |
|
---|
| 558 | - Adjust feature detection of `React.startTransition` to fix webpack + react 17 compilation error ([#10569](https://github.com/remix-run/react-router/pull/10569))
|
---|
| 559 | - Updated dependencies:
|
---|
| 560 | - `react-router@6.12.1`
|
---|
| 561 |
|
---|
| 562 | ## 6.12.0
|
---|
| 563 |
|
---|
| 564 | ### Minor Changes
|
---|
| 565 |
|
---|
| 566 | - Wrap internal router state updates with `React.startTransition` if it exists ([#10438](https://github.com/remix-run/react-router/pull/10438))
|
---|
| 567 |
|
---|
| 568 | ### Patch Changes
|
---|
| 569 |
|
---|
| 570 | - Re-throw `DOMException` (`DataCloneError`) when attempting to perform a `PUSH` navigation with non-serializable state. ([#10427](https://github.com/remix-run/react-router/pull/10427))
|
---|
| 571 | - Updated dependencies:
|
---|
| 572 | - `@remix-run/router@1.6.3`
|
---|
| 573 | - `react-router@6.12.0`
|
---|
| 574 |
|
---|
| 575 | ## 6.11.2
|
---|
| 576 |
|
---|
| 577 | ### Patch Changes
|
---|
| 578 |
|
---|
| 579 | - Export `SetURLSearchParams` type ([#10444](https://github.com/remix-run/react-router/pull/10444))
|
---|
| 580 | - Updated dependencies:
|
---|
| 581 | - `react-router@6.11.2`
|
---|
| 582 | - `@remix-run/router@1.6.2`
|
---|
| 583 |
|
---|
| 584 | ## 6.11.1
|
---|
| 585 |
|
---|
| 586 | ### Patch Changes
|
---|
| 587 |
|
---|
| 588 | - Updated dependencies:
|
---|
| 589 | - `react-router@6.11.1`
|
---|
| 590 | - `@remix-run/router@1.6.1`
|
---|
| 591 |
|
---|
| 592 | ## 6.11.0
|
---|
| 593 |
|
---|
| 594 | ### Minor Changes
|
---|
| 595 |
|
---|
| 596 | - Enable `basename` support in `useFetcher` ([#10336](https://github.com/remix-run/react-router/pull/10336))
|
---|
| 597 | - If you were previously working around this issue by manually prepending the `basename` then you will need to remove the manually prepended `basename` from your `fetcher` calls (`fetcher.load('/basename/route') -> fetcher.load('/route')`)
|
---|
| 598 |
|
---|
| 599 | ### Patch Changes
|
---|
| 600 |
|
---|
| 601 | - Fix inadvertent re-renders when using `Component` instead of `element` on a route definition ([#10287](https://github.com/remix-run/react-router/pull/10287))
|
---|
| 602 | - Fail gracefully on `<Link to="//">` and other invalid URL values ([#10367](https://github.com/remix-run/react-router/pull/10367))
|
---|
| 603 | - 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))
|
---|
| 604 | - Add static prop to `StaticRouterProvider`'s internal `Router` component ([#10401](https://github.com/remix-run/react-router/pull/10401))
|
---|
| 605 | - 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))
|
---|
| 606 | - Updated dependencies:
|
---|
| 607 | - `react-router@6.11.0`
|
---|
| 608 | - `@remix-run/router@1.6.0`
|
---|
| 609 |
|
---|
| 610 | ## 6.10.0
|
---|
| 611 |
|
---|
| 612 | ### Minor Changes
|
---|
| 613 |
|
---|
| 614 | - 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))
|
---|
| 615 |
|
---|
| 616 | - When `future.v7_normalizeFormMethod === false` (default v6 behavior),
|
---|
| 617 | - `useNavigation().formMethod` is lowercase
|
---|
| 618 | - `useFetcher().formMethod` is lowercase
|
---|
| 619 | - When `future.v7_normalizeFormMethod === true`:
|
---|
| 620 | - `useNavigation().formMethod` is uppercase
|
---|
| 621 | - `useFetcher().formMethod` is uppercase
|
---|
| 622 |
|
---|
| 623 | ### Patch Changes
|
---|
| 624 |
|
---|
| 625 | - Fix `createStaticHandler` to also check for `ErrorBoundary` on routes in addition to `errorElement` ([#10190](https://github.com/remix-run/react-router/pull/10190))
|
---|
| 626 | - Updated dependencies:
|
---|
| 627 | - `@remix-run/router@1.5.0`
|
---|
| 628 | - `react-router@6.10.0`
|
---|
| 629 |
|
---|
| 630 | ## 6.9.0
|
---|
| 631 |
|
---|
| 632 | ### Minor Changes
|
---|
| 633 |
|
---|
| 634 | - 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))
|
---|
| 635 |
|
---|
| 636 | **Example JSON Syntax**
|
---|
| 637 |
|
---|
| 638 | ```jsx
|
---|
| 639 | // Both of these work the same:
|
---|
| 640 | const elementRoutes = [{
|
---|
| 641 | path: '/',
|
---|
| 642 | element: <Home />,
|
---|
| 643 | errorElement: <HomeError />,
|
---|
| 644 | }]
|
---|
| 645 |
|
---|
| 646 | const componentRoutes = [{
|
---|
| 647 | path: '/',
|
---|
| 648 | Component: Home,
|
---|
| 649 | ErrorBoundary: HomeError,
|
---|
| 650 | }]
|
---|
| 651 |
|
---|
| 652 | function Home() { ... }
|
---|
| 653 | function HomeError() { ... }
|
---|
| 654 | ```
|
---|
| 655 |
|
---|
| 656 | **Example JSX Syntax**
|
---|
| 657 |
|
---|
| 658 | ```jsx
|
---|
| 659 | // Both of these work the same:
|
---|
| 660 | const elementRoutes = createRoutesFromElements(
|
---|
| 661 | <Route path='/' element={<Home />} errorElement={<HomeError /> } />
|
---|
| 662 | );
|
---|
| 663 |
|
---|
| 664 | const componentRoutes = createRoutesFromElements(
|
---|
| 665 | <Route path='/' Component={Home} ErrorBoundary={HomeError} />
|
---|
| 666 | );
|
---|
| 667 |
|
---|
| 668 | function Home() { ... }
|
---|
| 669 | function HomeError() { ... }
|
---|
| 670 | ```
|
---|
| 671 |
|
---|
| 672 | - **Introducing Lazy Route Modules!** ([#10045](https://github.com/remix-run/react-router/pull/10045))
|
---|
| 673 |
|
---|
| 674 | 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`).
|
---|
| 675 |
|
---|
| 676 | 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.
|
---|
| 677 |
|
---|
| 678 | Your `lazy` functions will typically return the result of a dynamic import.
|
---|
| 679 |
|
---|
| 680 | ```jsx
|
---|
| 681 | // In this example, we assume most folks land on the homepage so we include that
|
---|
| 682 | // in our critical-path bundle, but then we lazily load modules for /a and /b so
|
---|
| 683 | // they don't load until the user navigates to those routes
|
---|
| 684 | let routes = createRoutesFromElements(
|
---|
| 685 | <Route path="/" element={<Layout />}>
|
---|
| 686 | <Route index element={<Home />} />
|
---|
| 687 | <Route path="a" lazy={() => import("./a")} />
|
---|
| 688 | <Route path="b" lazy={() => import("./b")} />
|
---|
| 689 | </Route>
|
---|
| 690 | );
|
---|
| 691 | ```
|
---|
| 692 |
|
---|
| 693 | Then in your lazy route modules, export the properties you want defined for the route:
|
---|
| 694 |
|
---|
| 695 | ```jsx
|
---|
| 696 | export async function loader({ request }) {
|
---|
| 697 | let data = await fetchData(request);
|
---|
| 698 | return json(data);
|
---|
| 699 | }
|
---|
| 700 |
|
---|
| 701 | // Export a `Component` directly instead of needing to create a React Element from it
|
---|
| 702 | export function Component() {
|
---|
| 703 | let data = useLoaderData();
|
---|
| 704 |
|
---|
| 705 | return (
|
---|
| 706 | <>
|
---|
| 707 | <h1>You made it!</h1>
|
---|
| 708 | <p>{data}</p>
|
---|
| 709 | </>
|
---|
| 710 | );
|
---|
| 711 | }
|
---|
| 712 |
|
---|
| 713 | // Export an `ErrorBoundary` directly instead of needing to create a React Element from it
|
---|
| 714 | export function ErrorBoundary() {
|
---|
| 715 | let error = useRouteError();
|
---|
| 716 | return isRouteErrorResponse(error) ? (
|
---|
| 717 | <h1>
|
---|
| 718 | {error.status} {error.statusText}
|
---|
| 719 | </h1>
|
---|
| 720 | ) : (
|
---|
| 721 | <h1>{error.message || error}</h1>
|
---|
| 722 | );
|
---|
| 723 | }
|
---|
| 724 | ```
|
---|
| 725 |
|
---|
| 726 | 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.
|
---|
| 727 |
|
---|
| 728 | 🙌 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).
|
---|
| 729 |
|
---|
| 730 | - Updated dependencies:
|
---|
| 731 | - `react-router@6.9.0`
|
---|
| 732 | - `@remix-run/router@1.4.0`
|
---|
| 733 |
|
---|
| 734 | ## 6.8.2
|
---|
| 735 |
|
---|
| 736 | ### Patch Changes
|
---|
| 737 |
|
---|
| 738 | - Treat same-origin absolute URLs in `<Link to>` as external if they are outside of the router `basename` ([#10135](https://github.com/remix-run/react-router/pull/10135))
|
---|
| 739 | - Fix `useBlocker` to return `IDLE_BLOCKER` during SSR ([#10046](https://github.com/remix-run/react-router/pull/10046))
|
---|
| 740 | - Fix SSR of absolute `<Link to>` urls ([#10112](https://github.com/remix-run/react-router/pull/10112))
|
---|
| 741 | - Properly escape HTML characters in `StaticRouterProvider` serialized hydration data ([#10068](https://github.com/remix-run/react-router/pull/10068))
|
---|
| 742 | - Updated dependencies:
|
---|
| 743 | - `@remix-run/router@1.3.3`
|
---|
| 744 | - `react-router@6.8.2`
|
---|
| 745 |
|
---|
| 746 | ## 6.8.1
|
---|
| 747 |
|
---|
| 748 | ### Patch Changes
|
---|
| 749 |
|
---|
| 750 | - Improved absolute url detection in `Link` component (now also supports `mailto:` urls) ([#9994](https://github.com/remix-run/react-router/pull/9994))
|
---|
| 751 | - Fix partial object (search or hash only) pathnames losing current path value ([#10029](https://github.com/remix-run/react-router/pull/10029))
|
---|
| 752 | - Updated dependencies:
|
---|
| 753 | - `react-router@6.8.1`
|
---|
| 754 | - `@remix-run/router@1.3.2`
|
---|
| 755 |
|
---|
| 756 | ## 6.8.0
|
---|
| 757 |
|
---|
| 758 | ### Minor Changes
|
---|
| 759 |
|
---|
| 760 | - Support absolute URLs in `<Link to>`. If the URL is for the current origin, it will still do a client-side navigation. If the URL is for a different origin then it will do a fresh document request for the new origin. ([#9900](https://github.com/remix-run/react-router/pull/9900))
|
---|
| 761 |
|
---|
| 762 | ```tsx
|
---|
| 763 | <Link to="https://neworigin.com/some/path"> {/* Document request */}
|
---|
| 764 | <Link to="//neworigin.com/some/path"> {/* Document request */}
|
---|
| 765 | <Link to="https://www.currentorigin.com/path"> {/* Client-side navigation */}
|
---|
| 766 | ```
|
---|
| 767 |
|
---|
| 768 | ### Patch Changes
|
---|
| 769 |
|
---|
| 770 | - Fix bug with search params removal via `useSearchParams` ([#9969](https://github.com/remix-run/react-router/pull/9969))
|
---|
| 771 | - Respect `preventScrollReset` on `<fetcher.Form>` ([#9963](https://github.com/remix-run/react-router/pull/9963))
|
---|
| 772 | - Fix navigation for hash routers on manual URL changes ([#9980](https://github.com/remix-run/react-router/pull/9980))
|
---|
| 773 | - Use `pagehide` instead of `beforeunload` for `<ScrollRestoration>`. This has better cross-browser support, specifically on Mobile Safari. ([#9945](https://github.com/remix-run/react-router/pull/9945))
|
---|
| 774 | - Updated dependencies:
|
---|
| 775 | - `@remix-run/router@1.3.1`
|
---|
| 776 | - `react-router@6.8.0`
|
---|
| 777 |
|
---|
| 778 | ## 6.7.0
|
---|
| 779 |
|
---|
| 780 | ### Minor Changes
|
---|
| 781 |
|
---|
| 782 | - Add `unstable_useBlocker` hook for blocking navigations within the app's location origin ([#9709](https://github.com/remix-run/react-router/pull/9709))
|
---|
| 783 | - Add `unstable_usePrompt` hook for blocking navigations within the app's location origin ([#9932](https://github.com/remix-run/react-router/pull/9932))
|
---|
| 784 | - Add `preventScrollReset` prop to `<Form>` ([#9886](https://github.com/remix-run/react-router/pull/9886))
|
---|
| 785 |
|
---|
| 786 | ### Patch Changes
|
---|
| 787 |
|
---|
| 788 | - Added pass-through event listener options argument to `useBeforeUnload` ([#9709](https://github.com/remix-run/react-router/pull/9709))
|
---|
| 789 | - Streamline jsdom bug workaround in tests ([#9824](https://github.com/remix-run/react-router/pull/9824))
|
---|
| 790 | - Updated dependencies:
|
---|
| 791 | - `@remix-run/router@1.3.0`
|
---|
| 792 | - `react-router@6.7.0`
|
---|
| 793 |
|
---|
| 794 | ## 6.6.2
|
---|
| 795 |
|
---|
| 796 | ### Patch Changes
|
---|
| 797 |
|
---|
| 798 | - Ensure `useId` consistency during SSR ([#9805](https://github.com/remix-run/react-router/pull/9805))
|
---|
| 799 | - Updated dependencies:
|
---|
| 800 | - `react-router@6.6.2`
|
---|
| 801 |
|
---|
| 802 | ## 6.6.1
|
---|
| 803 |
|
---|
| 804 | ### Patch Changes
|
---|
| 805 |
|
---|
| 806 | - Updated dependencies:
|
---|
| 807 | - `@remix-run/router@1.2.1`
|
---|
| 808 | - `react-router@6.6.1`
|
---|
| 809 |
|
---|
| 810 | ## 6.6.0
|
---|
| 811 |
|
---|
| 812 | ### Minor Changes
|
---|
| 813 |
|
---|
| 814 | - Add `useBeforeUnload()` hook ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
---|
| 815 | - Remove `unstable_` prefix from `createStaticHandler`/`createStaticRouter`/`StaticRouterProvider` ([#9738](https://github.com/remix-run/react-router/pull/9738))
|
---|
| 816 |
|
---|
| 817 | ### Patch Changes
|
---|
| 818 |
|
---|
| 819 | - Proper hydration of `Error` objects from `StaticRouterProvider` ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
---|
| 820 | - Support uppercase `<Form method>` and `useSubmit` method values ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
---|
| 821 | - Skip initial scroll restoration for SSR apps with `hydrationData` ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
---|
| 822 | - Fix `<button formmethod>` form submission overriddes ([#9664](https://github.com/remix-run/react-router/pull/9664))
|
---|
| 823 | - Updated dependencies:
|
---|
| 824 | - `@remix-run/router@1.2.0`
|
---|
| 825 | - `react-router@6.6.0`
|
---|
| 826 |
|
---|
| 827 | ## 6.5.0
|
---|
| 828 |
|
---|
| 829 | ### Patch Changes
|
---|
| 830 |
|
---|
| 831 | - Updated dependencies:
|
---|
| 832 | - `react-router@6.5.0`
|
---|
| 833 | - `@remix-run/router@1.1.0`
|
---|
| 834 |
|
---|
| 835 | ## 6.4.5
|
---|
| 836 |
|
---|
| 837 | ### Patch Changes
|
---|
| 838 |
|
---|
| 839 | - Updated dependencies:
|
---|
| 840 | - `@remix-run/router@1.0.5`
|
---|
| 841 | - `react-router@6.4.5`
|
---|
| 842 |
|
---|
| 843 | ## 6.4.4
|
---|
| 844 |
|
---|
| 845 | ### Patch Changes
|
---|
| 846 |
|
---|
| 847 | - Fix issues with encoded characters in `NavLink` and descendant `<Routes>` ([#9589](https://github.com/remix-run/react-router/pull/9589), [#9647](https://github.com/remix-run/react-router/pull/9647))
|
---|
| 848 | - Properly serialize/deserialize `ErrorResponse` instances when using built-in hydration ([#9593](https://github.com/remix-run/react-router/pull/9593))
|
---|
| 849 | - Support `basename` in static data routers ([#9591](https://github.com/remix-run/react-router/pull/9591))
|
---|
| 850 | - Updated dependencies:
|
---|
| 851 | - `@remix-run/router@1.0.4`
|
---|
| 852 | - `react-router@6.4.4`
|
---|
| 853 |
|
---|
| 854 | ## 6.4.3
|
---|
| 855 |
|
---|
| 856 | ### Patch Changes
|
---|
| 857 |
|
---|
| 858 | - Fix hrefs generated for `createHashRouter` ([#9409](https://github.com/remix-run/react-router/pull/9409))
|
---|
| 859 | - fix encoding/matching issues with special chars ([#9477](https://github.com/remix-run/react-router/pull/9477), [#9496](https://github.com/remix-run/react-router/pull/9496))
|
---|
| 860 | - Properly support `index` routes with a `path` in `useResolvedPath` ([#9486](https://github.com/remix-run/react-router/pull/9486))
|
---|
| 861 | - Respect `relative=path` prop on `NavLink` ([#9453](https://github.com/remix-run/react-router/pull/9453))
|
---|
| 862 | - Fix `NavLink` behavior for root urls ([#9497](https://github.com/remix-run/react-router/pull/9497))
|
---|
| 863 | - Updated dependencies:
|
---|
| 864 | - `@remix-run/router@1.0.3`
|
---|
| 865 | - `react-router@6.4.3`
|
---|
| 866 |
|
---|
| 867 | ## 6.4.2
|
---|
| 868 |
|
---|
| 869 | ### Patch Changes
|
---|
| 870 |
|
---|
| 871 | - Respect `basename` in `useFormAction` ([#9352](https://github.com/remix-run/react-router/pull/9352))
|
---|
| 872 | - Enhance console error messages for invalid usage of data router hooks ([#9311](https://github.com/remix-run/react-router/pull/9311))
|
---|
| 873 | - 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))
|
---|
| 874 | - Updated dependencies:
|
---|
| 875 | - `react-router@6.4.2`
|
---|
| 876 | - `@remix-run/router@1.0.2`
|
---|
| 877 |
|
---|
| 878 | ## 6.4.1
|
---|
| 879 |
|
---|
| 880 | ### Patch Changes
|
---|
| 881 |
|
---|
| 882 | - Updated dependencies:
|
---|
| 883 | - `react-router@6.4.1`
|
---|
| 884 | - `@remix-run/router@1.0.1`
|
---|
| 885 |
|
---|
| 886 | ## 6.4.0
|
---|
| 887 |
|
---|
| 888 | 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).
|
---|
| 889 |
|
---|
| 890 | **New APIs**
|
---|
| 891 |
|
---|
| 892 | - Create your router with `createMemoryRouter`/`createBrowserRouter`/`createHashRouter`
|
---|
| 893 | - Render your router with `<RouterProvider>`
|
---|
| 894 | - Load data with a Route `loader` and mutate with a Route `action`
|
---|
| 895 | - Handle errors with Route `errorElement`
|
---|
| 896 | - Submit data with the new `<Form>` component
|
---|
| 897 | - Perform in-page data loads and mutations with `useFetcher()`
|
---|
| 898 | - Defer non-critical data with `defer` and `Await`
|
---|
| 899 | - Manage scroll position with `<ScrollRestoration>`
|
---|
| 900 |
|
---|
| 901 | **New Features**
|
---|
| 902 |
|
---|
| 903 | - Perform path-relative navigations with `<Link relative="path">` (#9160)
|
---|
| 904 |
|
---|
| 905 | **Bug Fixes**
|
---|
| 906 |
|
---|
| 907 | - Path resolution is now trailing slash agnostic (#8861)
|
---|
| 908 | - `useLocation` returns the scoped location inside a `<Routes location>` component (#9094)
|
---|
| 909 | - respect the `<Link replace>` prop if it is defined (#8779)
|
---|
| 910 |
|
---|
| 911 | **Updated Dependencies**
|
---|
| 912 |
|
---|
| 913 | - `react-router@6.4.0`
|
---|