From 9e7486b89e712b765d947297f228650cdc0c488e Mon Sep 17 00:00:00 2001 From: Andrew Patton Date: Wed, 13 Mar 2024 15:32:11 -0700 Subject: [PATCH 01/15] docs: Fix use-navigate.md example output in section on using useLocation with the URL constructor (#11344) --- contributors.yml | 1 + docs/hooks/use-navigate.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/contributors.yml b/contributors.yml index 02956eb71b..b8254acaa9 100644 --- a/contributors.yml +++ b/contributors.yml @@ -3,6 +3,7 @@ - abeadam - abhi-kr-2100 - AchThomas +- acusti - adamdotjs - adil62 - adriananin diff --git a/docs/hooks/use-navigate.md b/docs/hooks/use-navigate.md index 9aacff0ea7..3a80fc692d 100644 --- a/docs/hooks/use-navigate.md +++ b/docs/hooks/use-navigate.md @@ -109,7 +109,7 @@ new URL("..", window.origin + location.pathname); // With trailing slashes: new URL(".", window.origin + location.pathname + "/"); -// 'https://remix.run/docs/en/main/start/future-flags/' +// 'https://remix.run/docs/en/main/start/quickstart/' new URL("..", window.origin + location.pathname + "/"); // 'https://remix.run/docs/en/main/start/' ``` From 7bdef76522304fd60a09df609d35e18fc401978f Mon Sep 17 00:00:00 2001 From: Brooks Lybrand Date: Tue, 26 Mar 2024 12:31:10 -0500 Subject: [PATCH 02/15] Add changelog doc --- docs/start/changelog.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 docs/start/changelog.md diff --git a/docs/start/changelog.md b/docs/start/changelog.md new file mode 100644 index 0000000000..75c8f19716 --- /dev/null +++ b/docs/start/changelog.md @@ -0,0 +1,9 @@ +--- +title: Changelog +--- + +# Changelog + +See the detailed changelog for each release on [GitHub][changelog]. + +[changelog]: https://github.com/remix-run/react-router/blob/main/CHANGELOG.md \ No newline at end of file From 00ffa36b0aa5f046239acbc7675c83c43bfb4e2a Mon Sep 17 00:00:00 2001 From: Remix Run Bot Date: Tue, 26 Mar 2024 17:33:43 +0000 Subject: [PATCH 03/15] chore: format --- docs/start/changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/start/changelog.md b/docs/start/changelog.md index 75c8f19716..b44fc91b8c 100644 --- a/docs/start/changelog.md +++ b/docs/start/changelog.md @@ -6,4 +6,4 @@ title: Changelog See the detailed changelog for each release on [GitHub][changelog]. -[changelog]: https://github.com/remix-run/react-router/blob/main/CHANGELOG.md \ No newline at end of file +[changelog]: https://github.com/remix-run/react-router/blob/main/CHANGELOG.md From 6a2a3f9f987d530b752cdea9585af3aee96c1ac6 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Wed, 27 Mar 2024 10:24:41 -0400 Subject: [PATCH 04/15] Enter prerelease mode --- .changeset/data-strategy.md | 4 ++++ .changeset/pre.json | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 .changeset/pre.json diff --git a/.changeset/data-strategy.md b/.changeset/data-strategy.md index 1a70093bcf..f42a15bb40 100644 --- a/.changeset/data-strategy.md +++ b/.changeset/data-strategy.md @@ -1,5 +1,9 @@ --- "@remix-run/router": minor +"react-router": minor +"react-router-dom": minor +"react-router-dom-v5-compat": minor +"react-router-native": minor --- Add a new `unstable_dataStrategy` configuration option diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 0000000000..ef6ac484f0 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,12 @@ +{ + "mode": "pre", + "tag": "pre", + "initialVersions": { + "react-router": "6.22.3", + "react-router-dom": "6.22.3", + "react-router-dom-v5-compat": "6.22.3", + "react-router-native": "6.22.3", + "@remix-run/router": "1.15.3" + }, + "changesets": [] +} From f2e924e9adc38575894980f3ee1574dd37a785b9 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Wed, 27 Mar 2024 10:52:57 -0400 Subject: [PATCH 05/15] Add docs for unstable_dataStrategy and unstable_skipActionErrorRevalidation (#11356) --- docs/route/should-revalidate.md | 8 +- docs/routers/create-browser-router.md | 191 +++++++++++++++++++++++++- 2 files changed, 188 insertions(+), 11 deletions(-) diff --git a/docs/route/should-revalidate.md b/docs/route/should-revalidate.md index 04c58a330c..7148cdec41 100644 --- a/docs/route/should-revalidate.md +++ b/docs/route/should-revalidate.md @@ -38,10 +38,10 @@ This function allows you opt-out of revalidation for a route's [loader][loader] There are several instances where data is revalidated, keeping your UI in sync with your data automatically: -- After an [`action`][action] is called from a [`
`][form]. -- After an [`action`][action] is called from a [``][fetcher] -- After an [`action`][action] is called from [`useSubmit`][usesubmit] -- After an [`action`][action] is called from a [`fetcher.submit`][fetcher] +- After an [`action`][action] is called via: + - [``][form], [``][fetcher], [`useSubmit`][usesubmit], or [`fetcher.submit`][fetcher] + - When the `future.unstable_skipActionErrorRevalidation` flag is enabled, `loaders` will not revalidate by default if the `action` returns or throws a 4xx/5xx `Response` + - You can opt-into revalidation for these scenarios via `shouldRevalidate` and the `unstable_actionStatus` parameter - When an explicit revalidation is triggered via [`useRevalidator`][userevalidator] - When the [URL params][params] change for an already rendered route - When the URL Search params change diff --git a/docs/routers/create-browser-router.md b/docs/routers/create-browser-router.md index 600c2f40d2..4db3f5cab7 100644 --- a/docs/routers/create-browser-router.md +++ b/docs/routers/create-browser-router.md @@ -116,13 +116,14 @@ const router = createBrowserRouter(routes, { The following future flags are currently available: -| Flag | Description | -| ------------------------------------------- | --------------------------------------------------------------------- | -| `v7_fetcherPersist` | Delay active fetcher cleanup until they return to an `idle` state | -| `v7_normalizeFormMethod` | Normalize `useNavigation().formMethod` to be an uppercase HTTP Method | -| `v7_partialHydration` | Support partial hydration for Server-rendered apps | -| `v7_prependBasename` | Prepend the router basename to navigate/fetch paths | -| [`v7_relativeSplatPath`][relativesplatpath] | Fix buggy relative path resolution in splat routes | +| Flag | Description | +| ------------------------------------------- | ----------------------------------------------------------------------- | +| `v7_fetcherPersist` | Delay active fetcher cleanup until they return to an `idle` state | +| `v7_normalizeFormMethod` | Normalize `useNavigation().formMethod` to be an uppercase HTTP Method | +| `v7_partialHydration` | Support partial hydration for Server-rendered apps | +| `v7_prependBasename` | Prepend the router basename to navigate/fetch paths | +| [`v7_relativeSplatPath`][relativesplatpath] | Fix buggy relative path resolution in splat routes | +| `unstable_skipActionErrorRevalidation` | Do not revalidate by default if the action returns a 4xx/5xx `Response` | ## `hydrationData` @@ -181,6 +182,181 @@ const router = createBrowserRouter( ); ``` +## `unstable_dataStrategy` + +This is a low-level API intended for advanced use-cases. This overrides Remix's internal handling of `loader`/`action` execution, and if done incorrectly will break your app code. Please use with caution and perform the appropriate testing. + +This API is marked "unstable" so it is subject to breaking API changes in minor releases + +By default, React Router is opinionated about how your data is loaded/submitted - and most notably, executes all of your loaders in parallel for optimal data fetching. While we think this is the right behavior for most use-cases, we realize that there is no "one size fits all" solution when it comes to data fetching for the wide landscape of application requirements. + +The `unstable_dataStrategy` option gives you full control over how your loaders and actions are executed and lays the foundation to build in more advanced APIs such as middleware, context, and caching layers. Over time, we expect that we'll leverage this API internally to bring more first class APIs to React Router, but until then (and beyond), this is your way to add more advanced functionality for your applications data needs. + +### Type Declaration + +```ts +interface DataStrategyFunction { + (args: DataStrategyFunctionArgs): Promise< + HandlerResult[] + >; +} + +interface DataStrategyFunctionArgs { + request: Request; + params: Params; + context?: Context; + matches: DataStrategyMatch[]; +} + +interface DataStrategyMatch + extends AgnosticRouteMatch< + string, + AgnosticDataRouteObject + > { + shouldLoad: boolean; + resolve: ( + handlerOverride?: ( + handler: (ctx?: unknown) => DataFunctionReturnValue + ) => Promise + ) => Promise; +} + +interface HandlerResult { + type: "data" | "error"; + result: any; // data, Error, Response, DeferredData + status?: number; +} +``` + +`unstable_dataStrategy` receives the same arguments as a `loader`/`action` (`request`, `params`) but it also receives a `matches` array which is an array of the matched routes where each match is extended with 2 new fields for use in the data strategy function: + +- **`match.resolve`** - An async function that will resolve any `route.lazy` implementations and execute the route's handler (if necessary), returning a `HandlerResult` + - You should call `match.resolve` for _all_ matches every time to ensure that all lazy routes are properly resolved + - This does not mean you're calling the loader/action (the "handler") - resolve will only call the handler internally if needed and if you don't pass your own `handlerOverride` function parameter + - See the examples below for how to implement custom handler execution via `match.resolve` +- **`match.shouldLoad`** - A boolean value indicating whether this route handler needs to be called in this pass + - This array always includes _all_ matched routes even when only _some_ route handlers need to be called so that things like middleware can be implemented + - This is usually only needed if you are skipping the route handler entirely and implementing custom handler logic - since it lets you determine if that custom logic should run for this route or not + - For example: + - If you are on `/parent/child/a` and you navigate to `/parent/child/b` - you'll get an array of three matches (`[parent, child, b]`), but only `b` will have `shouldLoad=true` because the data for `parent` and `child` is already loaded + - If you are on `/parent/child/a` and you submit to `a`'s `action`, then only `a` will have `shouldLoad=true` for the action execution of `dataStrategy` + - After the `action`, `dataStrategy` will be called again for the `loader` revalidation, and all matches will have `shouldLoad=true` (assuming no custom `shouldRevalidate` implementations) + +The `dataStrategy` function should return a parallel array of `HandlerResult` instances, which is just an object of `{ type: 'data', result: unknown }` or `{ type: 'error', result: unknown }` depending on if the handler was successful or not. If the returned `handlerResult.result` is a `Response`, React Router will unwrap it for you (via `res.json` or `res.text`). If you need to do custom decoding of a `Response` but preserve the status code, you can return the decoded value in `handlerResult.result` and send the status along via `handlerResult.status` (for example, when using the `future.unstable_skipActionRevalidation` flag). `match.resolve()` will return a `HandlerResult` if you are not passing it a handler override function. If you are, then you need to wrap the `handler` result in a `HandlerResult` (see examples below). + +### Example Use Cases + +#### Adding logging + +In the simplest case, let's look at hooking into this API to add some logging for when our route loaders/actions execute: + +```ts +let router = createBrowserRouter(routes, { + unstable_dataStrategy({ request, matches }) { + return Promise.all( + matches.map(async (match) => { + console.log(`Processing route ${match.route.id}`); + // Don't override anything - just resolve route.lazy + call loader + let result = await match.resolve(); + console.log(`Done processing route ${match.route.id}`); + return result. + }) + ) + }, +}); +``` + +#### Middleware + +Let's define a middleware on each route via `handle` and call middleware sequentially first, then call all loaders in parallel - providing any data made available via the middleware: + +```ts +const routes [ + { + id: "parent", + path: "/parent", + loader({ request }, context) { /*...*/ }, + handle: { + async middleware({ request }, context) { + context.parent = "PARENT MIDDLEWARE"; + }, + }, + children: [ + { + id: "child", + path: "child", + loader({ request }, context) { /*...*/ }, + handle: { + async middleware({ request }, context) { + context.child = "CHILD MIDDLEWARE"; + }, + }, + }, + ], + }, +]; + +let router = createBrowserRouter(routes, { + unstable_dataStrategy({ request, params, matches }) { + // Run middleware sequentially and let them add data to `context` + let context = {}; + for (match of matches) { + if (match.route.handle?.middleware) { + await match.route.handle.middleware({ request, params }, context); + } + }); + + // Run loaders in parallel with the `context` value + return Promise.all( + matches.map((match, i) => + match.resolve(async (handler) => { + let result = await handler(context); + return { type: "data", result }; + }) + ) + ); + }, +}); +``` + +#### Custom Handler + +It's also possible you don't even want to define a loader implementation at the route level. Maybe you want to just determine the routes and issue a single GraphQL request for all of your data? You can do that by setting your `route.loader=true` so it qualifies as "having a loader", and then store GQL fragments on `route.handle`: + +```ts +const routes [ + { + id: "parent", + path: "/parent", + loader: true, + handle: { + gql: gql`fragment Parent on Whatever { parentField }` + }, + children: [ + { + id: "child", + path: "child", + loader: true, + handle: { + gql: gql`fragment Child on Whatever { childField }` + }, + }, + ], + }, +]; + +let router = createBrowserRouter(routes, { + unstable_dataStrategy({ request, params, matches }) { + // Compose route fragments into a single GQL payload + let gql = getFragmentsFromRouteHandles(matches); + let data = await fetchGql(gql); + // Parse results back out into individual route level HandlerResult's + let results = parseResultsFromGql(data); + return results; + }, +}); +``` + ## `window` Useful for environments like browser devtool plugins or testing to use a different window than the global `window`. @@ -199,3 +375,4 @@ Useful for environments like browser devtool plugins or testing to use a differe [clientloader]: https://remix.run/route/client-loader [hydratefallback]: ../route/hydrate-fallback-element [relativesplatpath]: ../hooks/use-resolved-path#splat-paths +[currying]: https://stackoverflow.com/questions/36314/what-is-currying From 88ec71a6d4159500cfbc69412112b128c669040a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 27 Mar 2024 10:53:50 -0400 Subject: [PATCH 06/15] chore: Update version for release (pre) (#11379) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 7 +++++- .../react-router-dom-v5-compat/CHANGELOG.md | 16 +++++++++++++ .../react-router-dom-v5-compat/package.json | 2 +- packages/react-router-dom/CHANGELOG.md | 15 ++++++++++++ packages/react-router-dom/package.json | 2 +- packages/react-router-native/CHANGELOG.md | 14 +++++++++++ packages/react-router-native/package.json | 2 +- packages/react-router/CHANGELOG.md | 14 +++++++++++ packages/react-router/package.json | 2 +- packages/router/CHANGELOG.md | 24 +++++++++++++++++++ packages/router/package.json | 2 +- 11 files changed, 94 insertions(+), 6 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index ef6ac484f0..aa7bfe2e1e 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -8,5 +8,10 @@ "react-router-native": "6.22.3", "@remix-run/router": "1.15.3" }, - "changesets": [] + "changesets": [ + "data-strategy", + "skip-action-revalidation", + "slow-flies-help", + "static-query-flags" + ] } diff --git a/packages/react-router-dom-v5-compat/CHANGELOG.md b/packages/react-router-dom-v5-compat/CHANGELOG.md index d2d34d7b39..be1a572873 100644 --- a/packages/react-router-dom-v5-compat/CHANGELOG.md +++ b/packages/react-router-dom-v5-compat/CHANGELOG.md @@ -1,5 +1,21 @@ # `react-router-dom-v5-compat` +## 6.23.0-pre.0 + +### Minor Changes + +- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) + + - This option allows Data Router applications to take control over the approach for executing route loaders and actions + - 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 + +### Patch Changes + +- Updated dependencies: + - `@remix-run/router@1.16.0-pre.0` + - `react-router@6.23.0-pre.0` + - `react-router-dom@6.23.0-pre.0` + ## 6.22.3 ### Patch Changes diff --git a/packages/react-router-dom-v5-compat/package.json b/packages/react-router-dom-v5-compat/package.json index 8d6224f0c7..3ebafcda5b 100644 --- a/packages/react-router-dom-v5-compat/package.json +++ b/packages/react-router-dom-v5-compat/package.json @@ -1,6 +1,6 @@ { "name": "react-router-dom-v5-compat", - "version": "6.22.3", + "version": "6.23.0-pre.0", "description": "Migration path to React Router v6 from v4/5", "keywords": [ "react", diff --git a/packages/react-router-dom/CHANGELOG.md b/packages/react-router-dom/CHANGELOG.md index 1122670fbf..c8fedbd8d1 100644 --- a/packages/react-router-dom/CHANGELOG.md +++ b/packages/react-router-dom/CHANGELOG.md @@ -1,5 +1,20 @@ # `react-router-dom` +## 6.23.0-pre.0 + +### Minor Changes + +- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) + + - This option allows Data Router applications to take control over the approach for executing route loaders and actions + - 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 + +### Patch Changes + +- Updated dependencies: + - `@remix-run/router@1.16.0-pre.0` + - `react-router@6.23.0-pre.0` + ## 6.22.3 ### Patch Changes diff --git a/packages/react-router-dom/package.json b/packages/react-router-dom/package.json index 8fdba2481d..69d2c713c9 100644 --- a/packages/react-router-dom/package.json +++ b/packages/react-router-dom/package.json @@ -1,6 +1,6 @@ { "name": "react-router-dom", - "version": "6.22.3", + "version": "6.23.0-pre.0", "description": "Declarative routing for React web applications", "keywords": [ "react", diff --git a/packages/react-router-native/CHANGELOG.md b/packages/react-router-native/CHANGELOG.md index 7f4c448440..749c09e777 100644 --- a/packages/react-router-native/CHANGELOG.md +++ b/packages/react-router-native/CHANGELOG.md @@ -1,5 +1,19 @@ # `react-router-native` +## 6.23.0-pre.0 + +### Minor Changes + +- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) + + - This option allows Data Router applications to take control over the approach for executing route loaders and actions + - 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 + +### Patch Changes + +- Updated dependencies: + - `react-router@6.23.0-pre.0` + ## 6.22.3 ### Patch Changes diff --git a/packages/react-router-native/package.json b/packages/react-router-native/package.json index 53b84afa26..40a2d94a03 100644 --- a/packages/react-router-native/package.json +++ b/packages/react-router-native/package.json @@ -1,6 +1,6 @@ { "name": "react-router-native", - "version": "6.22.3", + "version": "6.23.0-pre.0", "description": "Declarative routing for React Native applications", "keywords": [ "react", diff --git a/packages/react-router/CHANGELOG.md b/packages/react-router/CHANGELOG.md index adb2265b21..e4d20859dc 100644 --- a/packages/react-router/CHANGELOG.md +++ b/packages/react-router/CHANGELOG.md @@ -1,5 +1,19 @@ # `react-router` +## 6.23.0-pre.0 + +### Minor Changes + +- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) + + - This option allows Data Router applications to take control over the approach for executing route loaders and actions + - 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 + +### Patch Changes + +- Updated dependencies: + - `@remix-run/router@1.16.0-pre.0` + ## 6.22.3 ### Patch Changes diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 90fb508973..3070fb76ff 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -1,6 +1,6 @@ { "name": "react-router", - "version": "6.22.3", + "version": "6.23.0-pre.0", "description": "Declarative routing for React", "keywords": [ "react", diff --git a/packages/router/CHANGELOG.md b/packages/router/CHANGELOG.md index ac112bde1e..cdb5d4a8c2 100644 --- a/packages/router/CHANGELOG.md +++ b/packages/router/CHANGELOG.md @@ -1,5 +1,29 @@ # `@remix-run/router` +## 1.16.0-pre.0 + +### Minor Changes + +- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) + + - This option allows Data Router applications to take control over the approach for executing route loaders and actions + - 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 + +- Add a new `future.unstable_skipActionRevalidation` future flag ([#11098](https://github.com/remix-run/react-router/pull/11098)) + + - Currently, active loaders revalidate after any action, regardless of the result + - With this flag enabled, actions that return/throw a 4xx/5xx response status will no longer automatically revalidate + - This should reduce load on your server since it's rare that a 4xx/5xx should actually mutate any data + - If you need to revalidate after a 4xx/5xx result with this flag enabled, you can still do that via returning `true` from `shouldRevalidate` + - `shouldRevalidate` now also receives a new `unstable_actionStatus` argument alongside `actionResult` so you can make decision based on the status of the `action` response without having to encode it into the action data + +- - Move `unstable_dataStrategy` from `createStaticHandler` to `staticHandler.query` so it can be request-specific for use with the `ResponseStub` approach in Remix. It's not really applicable to `queryRoute` for now since that's a singular handler call anyway so any pre-processing/post/processing could be done there manually. ([#11377](https://github.com/remix-run/react-router/pull/11377)) + - Added a new `skipLoaders` flag to `staticHandler.query` for calling only the action in Remix Single Fetch +- Added 2 new options to the `staticHandler.query` method for use in Remix's Single Fetch implementation: ([#11098](https://github.com/remix-run/react-router/pull/11098)) + + - `loadRouteIds`: An optional array of route IDs to load if you wish to load a subset of the matched routes (useful for fine-grained revalidation) + - `skipLoaderErrorBubbling`: Disable error bubbling on loader executions for single-fetch scenarios where the client-side router will handle the bubbling + ## 1.15.3 ### Patch Changes diff --git a/packages/router/package.json b/packages/router/package.json index 68f6d00e32..7e87ef16c5 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -1,6 +1,6 @@ { "name": "@remix-run/router", - "version": "1.15.3", + "version": "1.16.0-pre.0", "description": "Nested/Data-driven/Framework-agnostic Routing", "keywords": [ "remix", From 45620235e45ba194d71578dd28e24e8f1ae2b349 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Wed, 27 Mar 2024 16:33:36 -0400 Subject: [PATCH 07/15] Prep release notes --- CHANGELOG.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44e8c5d6f1..2e7424ebdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -177,6 +177,35 @@ Date: YYYY-MM-DD **Full Changelog**: [`v6.X.Y...v6.X.Y`](https://github.com/remix-run/react-router/compare/react-router@6.X.Y...react-router@6.X.Y) --> +## v6.23.0 + +Date: 2024-04-03 + +### What's Changed + +#### Data Strategy (unstable) + +The new `unstable_dataStrategy` API is a low-level API designed for advanced use-cases where you need to take control over the data strategy for your `loader`/`action` functions. 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"](https://remix.run/docs/en/main/guides/single-fetch), user-land middleware/context APIs, automatic loader caching, and more. Please see the [docs](https://reactrouter.com/en/main/routers/create-browser-router#unstable_datastrategy) for more information. + +#### Skip Action Error Revalidation (unstable) + +Currently, all active `loader`'s revalidate after any `action` submission, regardless of the `action` result. However, in the majority of cases a `4xx`/`5xx` response from an `action` means that no data was actually changed and the revalidation is unnecessary. We've introduced a new `future.unstable_skipActionErrorRevalidation` flag that changes the behavior here, and we plan to make this the default in future version of React Router. + +With this flag enabled, `action`'s that return/throw a `4xx`/`5xx` response status will no longer automatically revalidate. If you need to revalidate after a `4xx`/`5xx` result with this flag enabled, you can still do that via returning `true` from `shouldRevalidate` - which now also receives a new `unstable_actionStatus` argument alongside `actionResult` so you can make decision based on the status of the `action` response without having to encode it into the action data. + +### Minor Changes + +- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) + - Move `unstable_dataStrategy` from `createStaticHandler` to `staticHandler.query` so it can be request-specific for use with the `ResponseStub` approach in Remix ([#11377](https://github.com/remix-run/react-router/pull/11377)) + - It's not really applicable to `queryRoute` for now since that's a singular handler call anyway so any pre-processing/post/processing could be done there manually +- `@remix-run/router` - Add a new `future.unstable_skipActionRevalidation` future flag ([#11098](https://github.com/remix-run/react-router/pull/11098)) +- `@remix-run/router` - SSR: Added 3 new options to the `staticHandler.query` method for use in Remix's Single Fetch implementation: ([#11098](https://github.com/remix-run/react-router/pull/11098), ([#11377](https://github.com/remix-run/react-router/pull/11377))) + - `loadRouteIds`: Optional array of route IDs to load a subset of the matched routes + - `skipLoaderErrorBubbling`: Disable error bubbling by the static handler + - `skipLoaders`: Only call the action on POST requests, don't call all of the loaders afterwards + +**Full Changelog**: [`v6.22.3...v6.23.0`](https://github.com/remix-run/react-router/compare/react-router@6.22.3...react-router@6.23.0) + ## v6.22.3 Date: 2024-03-07 From 4cb3ae2aab1bbaa5097779319a88591a74bda7b8 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Wed, 27 Mar 2024 16:34:09 -0400 Subject: [PATCH 08/15] Update changelog TOC --- CHANGELOG.md | 73 ++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e7424ebdc..74f3d3fe15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ We manage release notes in this file instead of the paginated Github Releases Pa Table of Contents - [React Router Releases](#react-router-releases) + - [v6.23.0](#v6230) + - [What's Changed](#whats-changed) + - [Data Strategy (unstable)](#data-strategy-unstable) + - [Skip Action Error Revalidation (unstable)](#skip-action-error-revalidation-unstable) + - [Minor Changes](#minor-changes) - [v6.22.3](#v6223) - [Patch Changes](#patch-changes) - [v6.22.2](#v6222) @@ -20,9 +25,9 @@ We manage release notes in this file instead of the paginated Github Releases Pa - [v6.22.1](#v6221) - [Patch Changes](#patch-changes-2) - [v6.22.0](#v6220) - - [What's Changed](#whats-changed) + - [What's Changed](#whats-changed-1) - [Core Web Vitals Technology Report Flag](#core-web-vitals-technology-report-flag) - - [Minor Changes](#minor-changes) + - [Minor Changes](#minor-changes-1) - [Patch Changes](#patch-changes-3) - [v6.21.3](#v6213) - [Patch Changes](#patch-changes-4) @@ -31,96 +36,96 @@ We manage release notes in this file instead of the paginated Github Releases Pa - [v6.21.1](#v6211) - [Patch Changes](#patch-changes-6) - [v6.21.0](#v6210) - - [What's Changed](#whats-changed-1) + - [What's Changed](#whats-changed-2) - [`future.v7_relativeSplatPath`](#futurev7_relativesplatpath) - [Partial Hydration](#partial-hydration) - - [Minor Changes](#minor-changes-1) + - [Minor Changes](#minor-changes-2) - [Patch Changes](#patch-changes-7) - [v6.20.1](#v6201) - [Patch Changes](#patch-changes-8) - [v6.20.0](#v6200) - - [Minor Changes](#minor-changes-2) + - [Minor Changes](#minor-changes-3) - [Patch Changes](#patch-changes-9) - [v6.19.0](#v6190) - - [What's Changed](#whats-changed-2) + - [What's Changed](#whats-changed-3) - [`unstable_flushSync` API](#unstable_flushsync-api) - - [Minor Changes](#minor-changes-3) + - [Minor Changes](#minor-changes-4) - [Patch Changes](#patch-changes-10) - [v6.18.0](#v6180) - - [What's Changed](#whats-changed-3) + - [What's Changed](#whats-changed-4) - [New Fetcher APIs](#new-fetcher-apis) - [Persistence Future Flag (`future.v7_fetcherPersist`)](#persistence-future-flag-futurev7_fetcherpersist) - - [Minor Changes](#minor-changes-4) + - [Minor Changes](#minor-changes-5) - [Patch Changes](#patch-changes-11) - [v6.17.0](#v6170) - - [What's Changed](#whats-changed-4) + - [What's Changed](#whats-changed-5) - [View Transitions 🚀](#view-transitions-) - - [Minor Changes](#minor-changes-5) + - [Minor Changes](#minor-changes-6) - [Patch Changes](#patch-changes-12) - [v6.16.0](#v6160) - - [Minor Changes](#minor-changes-6) + - [Minor Changes](#minor-changes-7) - [Patch Changes](#patch-changes-13) - [v6.15.0](#v6150) - - [Minor Changes](#minor-changes-7) + - [Minor Changes](#minor-changes-8) - [Patch Changes](#patch-changes-14) - [v6.14.2](#v6142) - [Patch Changes](#patch-changes-15) - [v6.14.1](#v6141) - [Patch Changes](#patch-changes-16) - [v6.14.0](#v6140) - - [What's Changed](#whats-changed-5) + - [What's Changed](#whats-changed-6) - [JSON/Text Submissions](#jsontext-submissions) - - [Minor Changes](#minor-changes-8) + - [Minor Changes](#minor-changes-9) - [Patch Changes](#patch-changes-17) - [v6.13.0](#v6130) - - [What's Changed](#whats-changed-6) - - [Minor Changes](#minor-changes-9) + - [What's Changed](#whats-changed-7) + - [Minor Changes](#minor-changes-10) - [Patch Changes](#patch-changes-18) - [v6.12.1](#v6121) - [Patch Changes](#patch-changes-19) - [v6.12.0](#v6120) - - [What's Changed](#whats-changed-7) + - [What's Changed](#whats-changed-8) - [`React.startTransition` support](#reactstarttransition-support) - - [Minor Changes](#minor-changes-10) + - [Minor Changes](#minor-changes-11) - [Patch Changes](#patch-changes-20) - [v6.11.2](#v6112) - [Patch Changes](#patch-changes-21) - [v6.11.1](#v6111) - [Patch Changes](#patch-changes-22) - [v6.11.0](#v6110) - - [Minor Changes](#minor-changes-11) + - [Minor Changes](#minor-changes-12) - [Patch Changes](#patch-changes-23) - [v6.10.0](#v6100) - - [What's Changed](#whats-changed-8) - - [Minor Changes](#minor-changes-12) + - [What's Changed](#whats-changed-9) + - [Minor Changes](#minor-changes-13) - [Patch Changes](#patch-changes-24) - [v6.9.0](#v690) - - [What's Changed](#whats-changed-9) + - [What's Changed](#whats-changed-10) - [`Component`/`ErrorBoundary` route properties](#componenterrorboundary-route-properties) - [Introducing Lazy Route Modules](#introducing-lazy-route-modules) - - [Minor Changes](#minor-changes-13) + - [Minor Changes](#minor-changes-14) - [Patch Changes](#patch-changes-25) - [v6.8.2](#v682) - [Patch Changes](#patch-changes-26) - [v6.8.1](#v681) - [Patch Changes](#patch-changes-27) - [v6.8.0](#v680) - - [Minor Changes](#minor-changes-14) + - [Minor Changes](#minor-changes-15) - [Patch Changes](#patch-changes-28) - [v6.7.0](#v670) - - [Minor Changes](#minor-changes-15) + - [Minor Changes](#minor-changes-16) - [Patch Changes](#patch-changes-29) - [v6.6.2](#v662) - [Patch Changes](#patch-changes-30) - [v6.6.1](#v661) - [Patch Changes](#patch-changes-31) - [v6.6.0](#v660) - - [What's Changed](#whats-changed-10) - - [Minor Changes](#minor-changes-16) - - [Patch Changes](#patch-changes-32) - - [v6.5.0](#v650) - [What's Changed](#whats-changed-11) - [Minor Changes](#minor-changes-17) + - [Patch Changes](#patch-changes-32) + - [v6.5.0](#v650) + - [What's Changed](#whats-changed-12) + - [Minor Changes](#minor-changes-18) - [Patch Changes](#patch-changes-33) - [v6.4.5](#v645) - [Patch Changes](#patch-changes-34) @@ -133,22 +138,22 @@ We manage release notes in this file instead of the paginated Github Releases Pa - [v6.4.1](#v641) - [Patch Changes](#patch-changes-38) - [v6.4.0](#v640) - - [What's Changed](#whats-changed-12) + - [What's Changed](#whats-changed-13) - [Remix Data APIs](#remix-data-apis) - [Patch Changes](#patch-changes-39) - [v6.3.0](#v630) - - [Minor Changes](#minor-changes-18) + - [Minor Changes](#minor-changes-19) - [v6.2.2](#v622) - [Patch Changes](#patch-changes-40) - [v6.2.1](#v621) - [Patch Changes](#patch-changes-41) - [v6.2.0](#v620) - - [Minor Changes](#minor-changes-19) + - [Minor Changes](#minor-changes-20) - [Patch Changes](#patch-changes-42) - [v6.1.1](#v611) - [Patch Changes](#patch-changes-43) - [v6.1.0](#v610) - - [Minor Changes](#minor-changes-20) + - [Minor Changes](#minor-changes-21) - [Patch Changes](#patch-changes-44) - [v6.0.2](#v602) - [Patch Changes](#patch-changes-45) From fa82b2f7d8053ec92738ce82dcff65997d219f93 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Wed, 27 Mar 2024 16:35:23 -0400 Subject: [PATCH 09/15] Updates --- CHANGELOG.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 74f3d3fe15..f36c3c8ec0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -200,9 +200,7 @@ With this flag enabled, `action`'s that return/throw a `4xx`/`5xx` response stat ### Minor Changes -- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) - - Move `unstable_dataStrategy` from `createStaticHandler` to `staticHandler.query` so it can be request-specific for use with the `ResponseStub` approach in Remix ([#11377](https://github.com/remix-run/react-router/pull/11377)) - - It's not really applicable to `queryRoute` for now since that's a singular handler call anyway so any pre-processing/post/processing could be done there manually +- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098), ([#11377](https://github.com/remix-run/react-router/pull/11377))) - `@remix-run/router` - Add a new `future.unstable_skipActionRevalidation` future flag ([#11098](https://github.com/remix-run/react-router/pull/11098)) - `@remix-run/router` - SSR: Added 3 new options to the `staticHandler.query` method for use in Remix's Single Fetch implementation: ([#11098](https://github.com/remix-run/react-router/pull/11098), ([#11377](https://github.com/remix-run/react-router/pull/11377))) - `loadRouteIds`: Optional array of route IDs to load a subset of the matched routes From 903b47fadd82cce5d4abad8f2460288c3c3da73f Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Fri, 29 Mar 2024 14:44:44 -0400 Subject: [PATCH 10/15] Remove flags (#11384) --- .changeset/funny-tips-beg.md | 5 ++ .changeset/slow-flies-help.md | 1 - .changeset/static-query-flags.md | 5 +- CHANGELOG.md | 5 +- package.json | 2 +- packages/router/__tests__/ssr-test.ts | 50 ----------------- packages/router/router.ts | 81 +++------------------------ 7 files changed, 16 insertions(+), 133 deletions(-) create mode 100644 .changeset/funny-tips-beg.md diff --git a/.changeset/funny-tips-beg.md b/.changeset/funny-tips-beg.md new file mode 100644 index 0000000000..f3ef8818e7 --- /dev/null +++ b/.changeset/funny-tips-beg.md @@ -0,0 +1,5 @@ +--- +"@remix-run/router": patch +--- + +[REMOVE] Remove staticHandler.query flags that we can implement in dataStrategy diff --git a/.changeset/slow-flies-help.md b/.changeset/slow-flies-help.md index 94d7064ecb..26479b827d 100644 --- a/.changeset/slow-flies-help.md +++ b/.changeset/slow-flies-help.md @@ -3,4 +3,3 @@ --- - Move `unstable_dataStrategy` from `createStaticHandler` to `staticHandler.query` so it can be request-specific for use with the `ResponseStub` approach in Remix. It's not really applicable to `queryRoute` for now since that's a singular handler call anyway so any pre-processing/post/processing could be done there manually. -- Added a new `skipLoaders` flag to `staticHandler.query` for calling only the action in Remix Single Fetch diff --git a/.changeset/static-query-flags.md b/.changeset/static-query-flags.md index 5bca02eca7..bbdfebc292 100644 --- a/.changeset/static-query-flags.md +++ b/.changeset/static-query-flags.md @@ -2,7 +2,4 @@ "@remix-run/router": minor --- -Added 2 new options to the `staticHandler.query` method for use in Remix's Single Fetch implementation: - -- `loadRouteIds`: An optional array of route IDs to load if you wish to load a subset of the matched routes (useful for fine-grained revalidation) -- `skipLoaderErrorBubbling`: Disable error bubbling on loader executions for single-fetch scenarios where the client-side router will handle the bubbling +Added a `skipLoaderErrorBubbling` flag to `staticHandler.query` to disable error bubbling on loader executions for single-fetch scenarios where the client-side router will handle the bubbling diff --git a/CHANGELOG.md b/CHANGELOG.md index f36c3c8ec0..0d3c549461 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -202,10 +202,7 @@ With this flag enabled, `action`'s that return/throw a `4xx`/`5xx` response stat - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098), ([#11377](https://github.com/remix-run/react-router/pull/11377))) - `@remix-run/router` - Add a new `future.unstable_skipActionRevalidation` future flag ([#11098](https://github.com/remix-run/react-router/pull/11098)) -- `@remix-run/router` - SSR: Added 3 new options to the `staticHandler.query` method for use in Remix's Single Fetch implementation: ([#11098](https://github.com/remix-run/react-router/pull/11098), ([#11377](https://github.com/remix-run/react-router/pull/11377))) - - `loadRouteIds`: Optional array of route IDs to load a subset of the matched routes - - `skipLoaderErrorBubbling`: Disable error bubbling by the static handler - - `skipLoaders`: Only call the action on POST requests, don't call all of the loaders afterwards +- `@remix-run/router` - SSR: Added a new `skipLoaderErrorBubbling` options to the `staticHandler.query` method to disable error bubbling by the static handler for use in Remix's Single Fetch implementation ([#11098](https://github.com/remix-run/react-router/pull/11098), ([#11377](https://github.com/remix-run/react-router/pull/11377))) **Full Changelog**: [`v6.22.3...v6.23.0`](https://github.com/remix-run/react-router/compare/react-router@6.22.3...react-router@6.23.0) diff --git a/package.json b/package.json index 605d1b9aca..af7348a3d1 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "none": "14.8 kB" }, "packages/react-router/dist/umd/react-router.production.min.js": { - "none": "17.2 kB" + "none": "17.21 kB" }, "packages/react-router-dom/dist/react-router-dom.production.min.js": { "none": "17.1 kB" diff --git a/packages/router/__tests__/ssr-test.ts b/packages/router/__tests__/ssr-test.ts index 19061e15e9..7795c08f70 100644 --- a/packages/router/__tests__/ssr-test.ts +++ b/packages/router/__tests__/ssr-test.ts @@ -1090,56 +1090,6 @@ describe("ssr", () => { expect(arg(childStub).context.sessionId).toBe("12345"); }); - it("should support a loadRouteIds parameter for granular loads", async () => { - let rootStub = jest.fn(() => "ROOT"); - let childStub = jest.fn(() => "CHILD"); - let actionStub = jest.fn(() => "CHILD ACTION"); - let { query } = createStaticHandler([ - { - id: "root", - path: "/", - loader: rootStub, - children: [ - { - id: "child", - path: "child", - action: actionStub, - loader: childStub, - }, - ], - }, - ]); - - let ctx = await query(createRequest("/child"), { - loadRouteIds: ["child"], - }); - expect(rootStub).not.toHaveBeenCalled(); - expect(childStub).toHaveBeenCalled(); - expect(ctx).toMatchObject({ - loaderData: { - child: "CHILD", - }, - }); - - actionStub.mockClear(); - rootStub.mockClear(); - childStub.mockClear(); - - ctx = await query(createSubmitRequest("/child"), { - loadRouteIds: ["child"], - }); - expect(rootStub).not.toHaveBeenCalled(); - expect(childStub).toHaveBeenCalled(); - expect(ctx).toMatchObject({ - actionData: { - child: "CHILD ACTION", - }, - loaderData: { - child: "CHILD", - }, - }); - }); - describe("deferred", () => { let { query } = createStaticHandler(SSR_ROUTES); diff --git a/packages/router/router.ts b/packages/router/router.ts index e99b844e66..7a7d2c0a61 100644 --- a/packages/router/router.ts +++ b/packages/router/router.ts @@ -405,9 +405,7 @@ export interface StaticHandler { query( request: Request, opts?: { - loadRouteIds?: string[]; requestContext?: unknown; - skipLoaders?: boolean; skipLoaderErrorBubbling?: boolean; unstable_dataStrategy?: DataStrategyFunction; } @@ -2988,30 +2986,22 @@ export function createStaticHandler( * propagate that out and return the raw Response so the HTTP server can * return it directly. * - * - `opts.loadRouteIds` is an optional array of routeIds to run only a subset of - * loaders during a query() call * - `opts.requestContext` is an optional server context that will be passed * to actions/loaders in the `context` parameter * - `opts.skipLoaderErrorBubbling` is an optional parameter that will prevent * the bubbling of errors which allows single-fetch-type implementations * where the client will handle the bubbling and we may need to return data * for the handling route - * - `opts.skipLoaders` is an optional parameter that will prevent loaders - * from running after an action */ async function query( request: Request, { - loadRouteIds, requestContext, skipLoaderErrorBubbling, - skipLoaders, unstable_dataStrategy, }: { - loadRouteIds?: string[]; requestContext?: unknown; skipLoaderErrorBubbling?: boolean; - skipLoaders?: boolean; unstable_dataStrategy?: DataStrategyFunction; } = {} ): Promise { @@ -3065,9 +3055,7 @@ export function createStaticHandler( matches, requestContext, unstable_dataStrategy || null, - loadRouteIds || null, skipLoaderErrorBubbling === true, - skipLoaders === true, null ); if (isResponse(result)) { @@ -3145,11 +3133,10 @@ export function createStaticHandler( matches, requestContext, null, - null, - false, false, match ); + if (isResponse(result)) { return result; } @@ -3185,9 +3172,7 @@ export function createStaticHandler( matches: AgnosticDataRouteMatch[], requestContext: unknown, unstable_dataStrategy: DataStrategyFunction | null, - loadRouteIds: string[] | null, skipLoaderErrorBubbling: boolean, - skipLoaders: boolean, routeMatch: AgnosticDataRouteMatch | null ): Promise | Response> { invariant( @@ -3203,9 +3188,7 @@ export function createStaticHandler( routeMatch || getTargetMatch(matches, location), requestContext, unstable_dataStrategy, - loadRouteIds, skipLoaderErrorBubbling, - skipLoaders, routeMatch != null ); return result; @@ -3216,7 +3199,6 @@ export function createStaticHandler( matches, requestContext, unstable_dataStrategy, - loadRouteIds, skipLoaderErrorBubbling, routeMatch ); @@ -3252,9 +3234,7 @@ export function createStaticHandler( actionMatch: AgnosticDataRouteMatch, requestContext: unknown, unstable_dataStrategy: DataStrategyFunction | null, - loadRouteIds: string[] | null, skipLoaderErrorBubbling: boolean, - skipLoaders: boolean, isRouteRequest: boolean ): Promise | Response> { let result: DataResult; @@ -3347,36 +3327,12 @@ export function createStaticHandler( let boundaryMatch = skipLoaderErrorBubbling ? actionMatch : findNearestBoundary(matches, actionMatch.route.id); - let statusCode = isRouteErrorResponse(result.error) - ? result.error.status - : result.statusCode != null - ? result.statusCode - : 500; - let actionHeaders = { - ...(result.headers ? { [actionMatch.route.id]: result.headers } : {}), - }; - - if (skipLoaders) { - return { - matches, - loaderData: {}, - actionData: {}, - errors: { - [boundaryMatch.route.id]: result.error, - }, - statusCode, - loaderHeaders: {}, - actionHeaders, - activeDeferreds: null, - }; - } let context = await loadRouteData( loaderRequest, matches, requestContext, unstable_dataStrategy, - loadRouteIds, skipLoaderErrorBubbling, null, [boundaryMatch.route.id, result] @@ -3385,28 +3341,15 @@ export function createStaticHandler( // action status codes take precedence over loader status codes return { ...context, - statusCode, + statusCode: isRouteErrorResponse(result.error) + ? result.error.status + : result.statusCode != null + ? result.statusCode + : 500, actionData: null, - actionHeaders, - }; - } - - let actionHeaders = result.headers - ? { [actionMatch.route.id]: result.headers } - : {}; - - if (skipLoaders) { - return { - matches, - loaderData: {}, - actionData: { - [actionMatch.route.id]: result.data, + actionHeaders: { + ...(result.headers ? { [actionMatch.route.id]: result.headers } : {}), }, - errors: null, - statusCode: result.statusCode || 200, - loaderHeaders: {}, - actionHeaders, - activeDeferreds: null, }; } @@ -3415,7 +3358,6 @@ export function createStaticHandler( matches, requestContext, unstable_dataStrategy, - loadRouteIds, skipLoaderErrorBubbling, null ); @@ -3438,7 +3380,6 @@ export function createStaticHandler( matches: AgnosticDataRouteMatch[], requestContext: unknown, unstable_dataStrategy: DataStrategyFunction | null, - loadRouteIds: string[] | null, skipLoaderErrorBubbling: boolean, routeMatch: AgnosticDataRouteMatch | null, pendingActionResult?: PendingActionResult @@ -3473,12 +3414,6 @@ export function createStaticHandler( (m) => m.route.loader || m.route.lazy ); - if (loadRouteIds) { - matchesToLoad = matchesToLoad.filter((m) => - loadRouteIds.includes(m.route.id) - ); - } - // Short circuit if we have no loaders to run (query()) if (matchesToLoad.length === 0) { return { From 8a20f324602afa7b867b5c218c919cc041f21c49 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 14:49:17 -0400 Subject: [PATCH 11/15] chore: Update version for release (pre) (#11387) Co-authored-by: github-actions[bot] --- .changeset/pre.json | 1 + packages/react-router-dom-v5-compat/CHANGELOG.md | 9 +++++++++ packages/react-router-dom-v5-compat/package.json | 2 +- packages/react-router-dom/CHANGELOG.md | 8 ++++++++ packages/react-router-dom/package.json | 2 +- packages/react-router-native/CHANGELOG.md | 7 +++++++ packages/react-router-native/package.json | 2 +- packages/react-router/CHANGELOG.md | 7 +++++++ packages/react-router/package.json | 2 +- packages/router/CHANGELOG.md | 6 ++++++ packages/router/package.json | 2 +- 11 files changed, 43 insertions(+), 5 deletions(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index aa7bfe2e1e..b2bbd246a7 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -10,6 +10,7 @@ }, "changesets": [ "data-strategy", + "funny-tips-beg", "skip-action-revalidation", "slow-flies-help", "static-query-flags" diff --git a/packages/react-router-dom-v5-compat/CHANGELOG.md b/packages/react-router-dom-v5-compat/CHANGELOG.md index be1a572873..31c10b82b0 100644 --- a/packages/react-router-dom-v5-compat/CHANGELOG.md +++ b/packages/react-router-dom-v5-compat/CHANGELOG.md @@ -1,5 +1,14 @@ # `react-router-dom-v5-compat` +## 6.23.0-pre.1 + +### Patch Changes + +- Updated dependencies: + - `@remix-run/router@1.16.0-pre.1` + - `react-router@6.23.0-pre.1` + - `react-router-dom@6.23.0-pre.1` + ## 6.23.0-pre.0 ### Minor Changes diff --git a/packages/react-router-dom-v5-compat/package.json b/packages/react-router-dom-v5-compat/package.json index 3ebafcda5b..4082dc6a46 100644 --- a/packages/react-router-dom-v5-compat/package.json +++ b/packages/react-router-dom-v5-compat/package.json @@ -1,6 +1,6 @@ { "name": "react-router-dom-v5-compat", - "version": "6.23.0-pre.0", + "version": "6.23.0-pre.1", "description": "Migration path to React Router v6 from v4/5", "keywords": [ "react", diff --git a/packages/react-router-dom/CHANGELOG.md b/packages/react-router-dom/CHANGELOG.md index c8fedbd8d1..3fd7068636 100644 --- a/packages/react-router-dom/CHANGELOG.md +++ b/packages/react-router-dom/CHANGELOG.md @@ -1,5 +1,13 @@ # `react-router-dom` +## 6.23.0-pre.1 + +### Patch Changes + +- Updated dependencies: + - `@remix-run/router@1.16.0-pre.1` + - `react-router@6.23.0-pre.1` + ## 6.23.0-pre.0 ### Minor Changes diff --git a/packages/react-router-dom/package.json b/packages/react-router-dom/package.json index 69d2c713c9..cd81ed1bf0 100644 --- a/packages/react-router-dom/package.json +++ b/packages/react-router-dom/package.json @@ -1,6 +1,6 @@ { "name": "react-router-dom", - "version": "6.23.0-pre.0", + "version": "6.23.0-pre.1", "description": "Declarative routing for React web applications", "keywords": [ "react", diff --git a/packages/react-router-native/CHANGELOG.md b/packages/react-router-native/CHANGELOG.md index 749c09e777..dee2fd4e8a 100644 --- a/packages/react-router-native/CHANGELOG.md +++ b/packages/react-router-native/CHANGELOG.md @@ -1,5 +1,12 @@ # `react-router-native` +## 6.23.0-pre.1 + +### Patch Changes + +- Updated dependencies: + - `react-router@6.23.0-pre.1` + ## 6.23.0-pre.0 ### Minor Changes diff --git a/packages/react-router-native/package.json b/packages/react-router-native/package.json index 40a2d94a03..0e48053c33 100644 --- a/packages/react-router-native/package.json +++ b/packages/react-router-native/package.json @@ -1,6 +1,6 @@ { "name": "react-router-native", - "version": "6.23.0-pre.0", + "version": "6.23.0-pre.1", "description": "Declarative routing for React Native applications", "keywords": [ "react", diff --git a/packages/react-router/CHANGELOG.md b/packages/react-router/CHANGELOG.md index e4d20859dc..4dfd1d2da6 100644 --- a/packages/react-router/CHANGELOG.md +++ b/packages/react-router/CHANGELOG.md @@ -1,5 +1,12 @@ # `react-router` +## 6.23.0-pre.1 + +### Patch Changes + +- Updated dependencies: + - `@remix-run/router@1.16.0-pre.1` + ## 6.23.0-pre.0 ### Minor Changes diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 3070fb76ff..9761112e80 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -1,6 +1,6 @@ { "name": "react-router", - "version": "6.23.0-pre.0", + "version": "6.23.0-pre.1", "description": "Declarative routing for React", "keywords": [ "react", diff --git a/packages/router/CHANGELOG.md b/packages/router/CHANGELOG.md index cdb5d4a8c2..9ba2d9ae32 100644 --- a/packages/router/CHANGELOG.md +++ b/packages/router/CHANGELOG.md @@ -1,5 +1,11 @@ # `@remix-run/router` +## 1.16.0-pre.1 + +### Patch Changes + +- [REMOVE] Remove staticHandler.query flags that we can implement in dataStrategy ([#11384](https://github.com/remix-run/react-router/pull/11384)) + ## 1.16.0-pre.0 ### Minor Changes diff --git a/packages/router/package.json b/packages/router/package.json index 7e87ef16c5..7ee7f7ba4e 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -1,6 +1,6 @@ { "name": "@remix-run/router", - "version": "1.16.0-pre.0", + "version": "1.16.0-pre.1", "description": "Nested/Data-driven/Framework-agnostic Routing", "keywords": [ "remix", From 792caa4cfbe745df8eab45dd2740cc72476cbfcc Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Fri, 29 Mar 2024 15:57:53 -0400 Subject: [PATCH 12/15] Docs updates --- docs/routers/create-browser-router.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/routers/create-browser-router.md b/docs/routers/create-browser-router.md index 4db3f5cab7..7a1f871964 100644 --- a/docs/routers/create-browser-router.md +++ b/docs/routers/create-browser-router.md @@ -184,9 +184,9 @@ const router = createBrowserRouter( ## `unstable_dataStrategy` -This is a low-level API intended for advanced use-cases. This overrides Remix's internal handling of `loader`/`action` execution, and if done incorrectly will break your app code. Please use with caution and perform the appropriate testing. +This is a low-level API intended for advanced use-cases. This overrides Remix's internal handling of `loader`/`action` execution, and if done incorrectly will break your app code. Please use with caution and perform the appropriate testing. -This API is marked "unstable" so it is subject to breaking API changes in minor releases +This API is marked "unstable" so it is subject to breaking API changes in minor releases By default, React Router is opinionated about how your data is loaded/submitted - and most notably, executes all of your loaders in parallel for optimal data fetching. While we think this is the right behavior for most use-cases, we realize that there is no "one size fits all" solution when it comes to data fetching for the wide landscape of application requirements. @@ -232,17 +232,17 @@ interface HandlerResult { - **`match.resolve`** - An async function that will resolve any `route.lazy` implementations and execute the route's handler (if necessary), returning a `HandlerResult` - You should call `match.resolve` for _all_ matches every time to ensure that all lazy routes are properly resolved - - This does not mean you're calling the loader/action (the "handler") - resolve will only call the handler internally if needed and if you don't pass your own `handlerOverride` function parameter + - This does not mean you're calling the loader/action (the "handler") - `resolve` will only call the `handler` internally if needed and if you don't pass your own `handlerOverride` function parameter - See the examples below for how to implement custom handler execution via `match.resolve` - **`match.shouldLoad`** - A boolean value indicating whether this route handler needs to be called in this pass - - This array always includes _all_ matched routes even when only _some_ route handlers need to be called so that things like middleware can be implemented - - This is usually only needed if you are skipping the route handler entirely and implementing custom handler logic - since it lets you determine if that custom logic should run for this route or not + - The `matches` array always includes _all_ matched routes even when only _some_ route handlers need to be called so that things like middleware can be implemented + - `shouldLoad` is usually only interesting if you are skipping the route handler entirely and implementing custom handler logic - since it lets you determine if that custom logic should run for this route or not - For example: - If you are on `/parent/child/a` and you navigate to `/parent/child/b` - you'll get an array of three matches (`[parent, child, b]`), but only `b` will have `shouldLoad=true` because the data for `parent` and `child` is already loaded - If you are on `/parent/child/a` and you submit to `a`'s `action`, then only `a` will have `shouldLoad=true` for the action execution of `dataStrategy` - After the `action`, `dataStrategy` will be called again for the `loader` revalidation, and all matches will have `shouldLoad=true` (assuming no custom `shouldRevalidate` implementations) -The `dataStrategy` function should return a parallel array of `HandlerResult` instances, which is just an object of `{ type: 'data', result: unknown }` or `{ type: 'error', result: unknown }` depending on if the handler was successful or not. If the returned `handlerResult.result` is a `Response`, React Router will unwrap it for you (via `res.json` or `res.text`). If you need to do custom decoding of a `Response` but preserve the status code, you can return the decoded value in `handlerResult.result` and send the status along via `handlerResult.status` (for example, when using the `future.unstable_skipActionRevalidation` flag). `match.resolve()` will return a `HandlerResult` if you are not passing it a handler override function. If you are, then you need to wrap the `handler` result in a `HandlerResult` (see examples below). +The `dataStrategy` function should return a parallel array of `HandlerResult` instances, which indicates if the handler was successful or not. If the returned `handlerResult.result` is a `Response`, React Router will unwrap it for you (via `res.json` or `res.text`). If you need to do custom decoding of a `Response` but preserve the status code, you can return the decoded value in `handlerResult.result` and send the status along via `handlerResult.status` (for example, when using the `future.unstable_skipActionRevalidation` flag). `match.resolve()` will return a `HandlerResult` if you are not passing it a handler override function. If you are, then you need to wrap the `handler` result in a `HandlerResult` (see examples below). ### Example Use Cases @@ -310,6 +310,8 @@ let router = createBrowserRouter(routes, { return Promise.all( matches.map((match, i) => match.resolve(async (handler) => { + // Whatever you pass to `handler` will be passed as the 2nd parameter + // to your loader/action let result = await handler(context); return { type: "data", result }; }) From 06953ccd18b0b962ce56f3b96ff9ab79beecd19c Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Tue, 23 Apr 2024 11:10:30 -0400 Subject: [PATCH 13/15] Update docs --- CHANGELOG.md | 6 ++++-- docs/routers/create-browser-router.md | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d3c549461..1fb1d76666 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -184,13 +184,15 @@ Date: YYYY-MM-DD ## v6.23.0 -Date: 2024-04-03 +Date: 2024-04-23 ### What's Changed #### Data Strategy (unstable) -The new `unstable_dataStrategy` API is a low-level API designed for advanced use-cases where you need to take control over the data strategy for your `loader`/`action` functions. 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"](https://remix.run/docs/en/main/guides/single-fetch), user-land middleware/context APIs, automatic loader caching, and more. Please see the [docs](https://reactrouter.com/en/main/routers/create-browser-router#unstable_datastrategy) for more information. +The new `unstable_dataStrategy` API is a low-level API designed for advanced use-cases where you need to take control over the data strategy for your `loader`/`action` functions. 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"](https://remix.run/docs/guides/single-fetch), user-land middleware/context APIs, automatic loader caching, and more. Please see the [docs](https://reactrouter.com/routers/create-browser-router#unstable_datastrategy) for more information. + +**Note:** This is a low-level API intended for advanced use-cases. This overrides React Router's internal handling of `loader`/`action` execution, and if done incorrectly will break your app code. Please use with caution and perform the appropriate testing. #### Skip Action Error Revalidation (unstable) diff --git a/docs/routers/create-browser-router.md b/docs/routers/create-browser-router.md index 7a1f871964..c9e734ed58 100644 --- a/docs/routers/create-browser-router.md +++ b/docs/routers/create-browser-router.md @@ -184,7 +184,7 @@ const router = createBrowserRouter( ## `unstable_dataStrategy` -This is a low-level API intended for advanced use-cases. This overrides Remix's internal handling of `loader`/`action` execution, and if done incorrectly will break your app code. Please use with caution and perform the appropriate testing. +This is a low-level API intended for advanced use-cases. This overrides React Router's internal handling of `loader`/`action` execution, and if done incorrectly will break your app code. Please use with caution and perform the appropriate testing. This API is marked "unstable" so it is subject to breaking API changes in minor releases From 4137aea8e64a2d84bce8e2010b832b519e109329 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Tue, 23 Apr 2024 11:10:47 -0400 Subject: [PATCH 14/15] Exit prerelease mode --- .changeset/pre.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/pre.json b/.changeset/pre.json index b2bbd246a7..8012661080 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -1,5 +1,5 @@ { - "mode": "pre", + "mode": "exit", "tag": "pre", "initialVersions": { "react-router": "6.22.3", From 82a3a778b23ed991fb71e6f188bb7d06cc3c7d62 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 11:28:31 -0400 Subject: [PATCH 15/15] chore: Update version for release (#11486) --- .changeset/data-strategy.md | 12 ----------- .changeset/funny-tips-beg.md | 5 ----- .changeset/pre.json | 18 ----------------- .changeset/skip-action-revalidation.md | 11 ---------- .changeset/slow-flies-help.md | 5 ----- .changeset/static-query-flags.md | 5 ----- CHANGELOG.md | 2 +- .../react-router-dom-v5-compat/CHANGELOG.md | 18 ++++------------- .../react-router-dom-v5-compat/package.json | 2 +- packages/react-router-dom/CHANGELOG.md | 15 +++----------- packages/react-router-dom/package.json | 2 +- packages/react-router-native/CHANGELOG.md | 12 ++--------- packages/react-router-native/package.json | 2 +- packages/react-router/CHANGELOG.md | 12 ++--------- packages/react-router/package.json | 2 +- packages/router/CHANGELOG.md | 20 +++---------------- packages/router/package.json | 2 +- 17 files changed, 20 insertions(+), 125 deletions(-) delete mode 100644 .changeset/data-strategy.md delete mode 100644 .changeset/funny-tips-beg.md delete mode 100644 .changeset/pre.json delete mode 100644 .changeset/skip-action-revalidation.md delete mode 100644 .changeset/slow-flies-help.md delete mode 100644 .changeset/static-query-flags.md diff --git a/.changeset/data-strategy.md b/.changeset/data-strategy.md deleted file mode 100644 index f42a15bb40..0000000000 --- a/.changeset/data-strategy.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -"@remix-run/router": minor -"react-router": minor -"react-router-dom": minor -"react-router-dom-v5-compat": minor -"react-router-native": minor ---- - -Add a new `unstable_dataStrategy` configuration option - -- This option allows Data Router applications to take control over the approach for executing route loaders and actions -- 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 diff --git a/.changeset/funny-tips-beg.md b/.changeset/funny-tips-beg.md deleted file mode 100644 index f3ef8818e7..0000000000 --- a/.changeset/funny-tips-beg.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@remix-run/router": patch ---- - -[REMOVE] Remove staticHandler.query flags that we can implement in dataStrategy diff --git a/.changeset/pre.json b/.changeset/pre.json deleted file mode 100644 index 8012661080..0000000000 --- a/.changeset/pre.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "mode": "exit", - "tag": "pre", - "initialVersions": { - "react-router": "6.22.3", - "react-router-dom": "6.22.3", - "react-router-dom-v5-compat": "6.22.3", - "react-router-native": "6.22.3", - "@remix-run/router": "1.15.3" - }, - "changesets": [ - "data-strategy", - "funny-tips-beg", - "skip-action-revalidation", - "slow-flies-help", - "static-query-flags" - ] -} diff --git a/.changeset/skip-action-revalidation.md b/.changeset/skip-action-revalidation.md deleted file mode 100644 index 379d4a7c13..0000000000 --- a/.changeset/skip-action-revalidation.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -"@remix-run/router": minor ---- - -Add a new `future.unstable_skipActionRevalidation` future flag - -- Currently, active loaders revalidate after any action, regardless of the result -- With this flag enabled, actions that return/throw a 4xx/5xx response status will no longer automatically revalidate -- This should reduce load on your server since it's rare that a 4xx/5xx should actually mutate any data -- If you need to revalidate after a 4xx/5xx result with this flag enabled, you can still do that via returning `true` from `shouldRevalidate` -- `shouldRevalidate` now also receives a new `unstable_actionStatus` argument alongside `actionResult` so you can make decision based on the status of the `action` response without having to encode it into the action data diff --git a/.changeset/slow-flies-help.md b/.changeset/slow-flies-help.md deleted file mode 100644 index 26479b827d..0000000000 --- a/.changeset/slow-flies-help.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@remix-run/router": minor ---- - -- Move `unstable_dataStrategy` from `createStaticHandler` to `staticHandler.query` so it can be request-specific for use with the `ResponseStub` approach in Remix. It's not really applicable to `queryRoute` for now since that's a singular handler call anyway so any pre-processing/post/processing could be done there manually. diff --git a/.changeset/static-query-flags.md b/.changeset/static-query-flags.md deleted file mode 100644 index bbdfebc292..0000000000 --- a/.changeset/static-query-flags.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@remix-run/router": minor ---- - -Added a `skipLoaderErrorBubbling` flag to `staticHandler.query` to disable error bubbling on loader executions for single-fetch scenarios where the client-side router will handle the bubbling diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fb1d76666..dcd3e0e023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -202,7 +202,7 @@ With this flag enabled, `action`'s that return/throw a `4xx`/`5xx` response stat ### Minor Changes -- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098), ([#11377](https://github.com/remix-run/react-router/pull/11377))) +- Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098), [#11377](https://github.com/remix-run/react-router/pull/11377)) - `@remix-run/router` - Add a new `future.unstable_skipActionRevalidation` future flag ([#11098](https://github.com/remix-run/react-router/pull/11098)) - `@remix-run/router` - SSR: Added a new `skipLoaderErrorBubbling` options to the `staticHandler.query` method to disable error bubbling by the static handler for use in Remix's Single Fetch implementation ([#11098](https://github.com/remix-run/react-router/pull/11098), ([#11377](https://github.com/remix-run/react-router/pull/11377))) diff --git a/packages/react-router-dom-v5-compat/CHANGELOG.md b/packages/react-router-dom-v5-compat/CHANGELOG.md index 31c10b82b0..ee5bac22db 100644 --- a/packages/react-router-dom-v5-compat/CHANGELOG.md +++ b/packages/react-router-dom-v5-compat/CHANGELOG.md @@ -1,29 +1,19 @@ # `react-router-dom-v5-compat` -## 6.23.0-pre.1 - -### Patch Changes - -- Updated dependencies: - - `@remix-run/router@1.16.0-pre.1` - - `react-router@6.23.0-pre.1` - - `react-router-dom@6.23.0-pre.1` - -## 6.23.0-pre.0 +## 6.23.0 ### Minor Changes - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) - - This option allows Data Router applications to take control over the approach for executing route loaders and actions - 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 ### Patch Changes - Updated dependencies: - - `@remix-run/router@1.16.0-pre.0` - - `react-router@6.23.0-pre.0` - - `react-router-dom@6.23.0-pre.0` + - `@remix-run/router@1.16.0` + - `react-router@6.23.0` + - `react-router-dom@6.23.0` ## 6.22.3 diff --git a/packages/react-router-dom-v5-compat/package.json b/packages/react-router-dom-v5-compat/package.json index 4082dc6a46..cccca5fe5d 100644 --- a/packages/react-router-dom-v5-compat/package.json +++ b/packages/react-router-dom-v5-compat/package.json @@ -1,6 +1,6 @@ { "name": "react-router-dom-v5-compat", - "version": "6.23.0-pre.1", + "version": "6.23.0", "description": "Migration path to React Router v6 from v4/5", "keywords": [ "react", diff --git a/packages/react-router-dom/CHANGELOG.md b/packages/react-router-dom/CHANGELOG.md index 3fd7068636..c19bc004b8 100644 --- a/packages/react-router-dom/CHANGELOG.md +++ b/packages/react-router-dom/CHANGELOG.md @@ -1,27 +1,18 @@ # `react-router-dom` -## 6.23.0-pre.1 - -### Patch Changes - -- Updated dependencies: - - `@remix-run/router@1.16.0-pre.1` - - `react-router@6.23.0-pre.1` - -## 6.23.0-pre.0 +## 6.23.0 ### Minor Changes - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) - - This option allows Data Router applications to take control over the approach for executing route loaders and actions - 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 ### Patch Changes - Updated dependencies: - - `@remix-run/router@1.16.0-pre.0` - - `react-router@6.23.0-pre.0` + - `@remix-run/router@1.16.0` + - `react-router@6.23.0` ## 6.22.3 diff --git a/packages/react-router-dom/package.json b/packages/react-router-dom/package.json index cd81ed1bf0..407c913a5d 100644 --- a/packages/react-router-dom/package.json +++ b/packages/react-router-dom/package.json @@ -1,6 +1,6 @@ { "name": "react-router-dom", - "version": "6.23.0-pre.1", + "version": "6.23.0", "description": "Declarative routing for React web applications", "keywords": [ "react", diff --git a/packages/react-router-native/CHANGELOG.md b/packages/react-router-native/CHANGELOG.md index dee2fd4e8a..5da49a7c3d 100644 --- a/packages/react-router-native/CHANGELOG.md +++ b/packages/react-router-native/CHANGELOG.md @@ -1,25 +1,17 @@ # `react-router-native` -## 6.23.0-pre.1 - -### Patch Changes - -- Updated dependencies: - - `react-router@6.23.0-pre.1` - -## 6.23.0-pre.0 +## 6.23.0 ### Minor Changes - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) - - This option allows Data Router applications to take control over the approach for executing route loaders and actions - 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 ### Patch Changes - Updated dependencies: - - `react-router@6.23.0-pre.0` + - `react-router@6.23.0` ## 6.22.3 diff --git a/packages/react-router-native/package.json b/packages/react-router-native/package.json index 0e48053c33..adfe7b83a1 100644 --- a/packages/react-router-native/package.json +++ b/packages/react-router-native/package.json @@ -1,6 +1,6 @@ { "name": "react-router-native", - "version": "6.23.0-pre.1", + "version": "6.23.0", "description": "Declarative routing for React Native applications", "keywords": [ "react", diff --git a/packages/react-router/CHANGELOG.md b/packages/react-router/CHANGELOG.md index 4dfd1d2da6..53b8b016ad 100644 --- a/packages/react-router/CHANGELOG.md +++ b/packages/react-router/CHANGELOG.md @@ -1,25 +1,17 @@ # `react-router` -## 6.23.0-pre.1 - -### Patch Changes - -- Updated dependencies: - - `@remix-run/router@1.16.0-pre.1` - -## 6.23.0-pre.0 +## 6.23.0 ### Minor Changes - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) - - This option allows Data Router applications to take control over the approach for executing route loaders and actions - 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 ### Patch Changes - Updated dependencies: - - `@remix-run/router@1.16.0-pre.0` + - `@remix-run/router@1.16.0` ## 6.22.3 diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 9761112e80..692a6b3a71 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -1,6 +1,6 @@ { "name": "react-router", - "version": "6.23.0-pre.1", + "version": "6.23.0", "description": "Declarative routing for React", "keywords": [ "react", diff --git a/packages/router/CHANGELOG.md b/packages/router/CHANGELOG.md index 9ba2d9ae32..f63876348a 100644 --- a/packages/router/CHANGELOG.md +++ b/packages/router/CHANGELOG.md @@ -1,34 +1,20 @@ # `@remix-run/router` -## 1.16.0-pre.1 - -### Patch Changes - -- [REMOVE] Remove staticHandler.query flags that we can implement in dataStrategy ([#11384](https://github.com/remix-run/react-router/pull/11384)) - -## 1.16.0-pre.0 +## 1.16.0 ### Minor Changes - Add a new `unstable_dataStrategy` configuration option ([#11098](https://github.com/remix-run/react-router/pull/11098)) - - This option allows Data Router applications to take control over the approach for executing route loaders and actions - 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 - +- Move `unstable_dataStrategy` from `createStaticHandler` to `staticHandler.query` so it can be request-specific for use with the `ResponseStub` approach in Remix. It's not really applicable to `queryRoute` for now since that's a singular handler call anyway so any pre-processing/post/processing could be done there manually. ([#11377](https://github.com/remix-run/react-router/pull/11377)) - Add a new `future.unstable_skipActionRevalidation` future flag ([#11098](https://github.com/remix-run/react-router/pull/11098)) - - Currently, active loaders revalidate after any action, regardless of the result - With this flag enabled, actions that return/throw a 4xx/5xx response status will no longer automatically revalidate - This should reduce load on your server since it's rare that a 4xx/5xx should actually mutate any data - If you need to revalidate after a 4xx/5xx result with this flag enabled, you can still do that via returning `true` from `shouldRevalidate` - `shouldRevalidate` now also receives a new `unstable_actionStatus` argument alongside `actionResult` so you can make decision based on the status of the `action` response without having to encode it into the action data - -- - Move `unstable_dataStrategy` from `createStaticHandler` to `staticHandler.query` so it can be request-specific for use with the `ResponseStub` approach in Remix. It's not really applicable to `queryRoute` for now since that's a singular handler call anyway so any pre-processing/post/processing could be done there manually. ([#11377](https://github.com/remix-run/react-router/pull/11377)) - - Added a new `skipLoaders` flag to `staticHandler.query` for calling only the action in Remix Single Fetch -- Added 2 new options to the `staticHandler.query` method for use in Remix's Single Fetch implementation: ([#11098](https://github.com/remix-run/react-router/pull/11098)) - - - `loadRouteIds`: An optional array of route IDs to load if you wish to load a subset of the matched routes (useful for fine-grained revalidation) - - `skipLoaderErrorBubbling`: Disable error bubbling on loader executions for single-fetch scenarios where the client-side router will handle the bubbling +- Added a `skipLoaderErrorBubbling` flag to `staticHandler.query` to disable error bubbling on loader executions for single-fetch scenarios where the client-side router will handle the bubbling ([#11098](https://github.com/remix-run/react-router/pull/11098)) ## 1.15.3 diff --git a/packages/router/package.json b/packages/router/package.json index 7ee7f7ba4e..2560dadb8d 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -1,6 +1,6 @@ { "name": "@remix-run/router", - "version": "1.16.0-pre.1", + "version": "1.16.0", "description": "Nested/Data-driven/Framework-agnostic Routing", "keywords": [ "remix",