react-router 7.2.0-pre.1 → 7.2.0-pre.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # `react-router`
2
2
 
3
+ ## 7.2.0-pre.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Properly handle revalidations to across a prerender/SPA boundary ([#13021](https://github.com/remix-run/react-router/pull/13021))
8
+
9
+ - In "hybrid" applications where some routes are pre-rendered and some are served from a SPA fallback, we need to avoid making `.data` requests if the path wasn't pre-rendered because the request will 404
10
+ - We don't know all the pre-rendered paths client-side, however:
11
+ - All `loader` data in `ssr:false` mode is static because it's generated at build time
12
+ - A route must use a `clientLoader` to do anything dynamic
13
+ - Therefore, if a route only has a `loader` and not a `clientLoader`, we disable revalidation by default because there is no new data to retrieve
14
+ - We short circuit and skip single fetch `.data` request logic if there are no server loaders with `shouldLoad=true` in our single fetch `dataStrategy`
15
+ - This ensures that the route doesn't cause a `.data` request that would 404 after a submission
16
+
17
+ - Error at build time in `ssr:false` + `prerender` apps for the edge case scenario of: ([#13021](https://github.com/remix-run/react-router/pull/13021))
18
+
19
+ - A parent route has only a `loader` (does not have a `clientLoader`)
20
+ - The parent route is pre-rendered
21
+ - The parent route has children routes which are not prerendered
22
+ - This means that when the child paths are loaded via the SPA fallback, the parent won't have any `loaderData` because there is no server on which to run the `loader`
23
+ - This can be resolved by either adding a parent `clientLoader` or pre-rendering the child paths
24
+ - If you add a `clientLoader`, calling the `serverLoader()` on non-prerendered paths will throw a 404
25
+
3
26
  ## 7.2.0-pre.1
4
27
 
5
28
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -5670,10 +5670,10 @@ function getSingleFetchDataStrategy(manifest, routeModules, ssr, getRouter) {
5670
5670
  return singleFetchActionStrategy(request, matches);
5671
5671
  }
5672
5672
  if (!ssr) {
5673
- let foundLoaderBelowRoot = matches.some(
5674
- (m) => m.route.id !== "root" && manifest.routes[m.route.id]?.hasLoader
5673
+ let foundRevalidatingServerLoader = matches.some(
5674
+ (m) => m.shouldLoad && manifest.routes[m.route.id]?.hasLoader && !manifest.routes[m.route.id]?.hasClientLoader
5675
5675
  );
5676
- if (!foundLoaderBelowRoot) {
5676
+ if (!foundRevalidatingServerLoader) {
5677
5677
  let matchesToLoad = matches.filter((m) => m.shouldLoad);
5678
5678
  let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
5679
5679
  return results.reduce(
@@ -6168,13 +6168,7 @@ function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest
6168
6168
  needsRevalidation
6169
6169
  );
6170
6170
  }
6171
- function preventInvalidServerHandlerCall(type, route, isSpaMode) {
6172
- if (isSpaMode) {
6173
- let fn = type === "action" ? "serverAction()" : "serverLoader()";
6174
- let msg = `You cannot call ${fn} in SPA Mode (routeId: "${route.id}")`;
6175
- console.error(msg);
6176
- throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
6177
- }
6171
+ function preventInvalidServerHandlerCall(type, route) {
6178
6172
  if (type === "loader" && !route.hasLoader || type === "action" && !route.hasAction) {
6179
6173
  let fn = type === "action" ? "serverAction()" : "serverLoader()";
6180
6174
  let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
@@ -6268,7 +6262,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6268
6262
  request,
6269
6263
  params,
6270
6264
  async serverLoader() {
6271
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6265
+ preventInvalidServerHandlerCall("loader", route);
6272
6266
  if (isHydrationRequest) {
6273
6267
  if (hasInitialData) {
6274
6268
  return initialData;
@@ -6307,7 +6301,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6307
6301
  request,
6308
6302
  params,
6309
6303
  async serverAction() {
6310
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6304
+ preventInvalidServerHandlerCall("action", route);
6311
6305
  return fetchServerAction(singleFetch);
6312
6306
  }
6313
6307
  });
@@ -6329,7 +6323,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6329
6323
  return clientLoader({
6330
6324
  ...args,
6331
6325
  async serverLoader() {
6332
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6326
+ preventInvalidServerHandlerCall("loader", route);
6333
6327
  return fetchServerLoader(singleFetch);
6334
6328
  }
6335
6329
  });
@@ -6354,7 +6348,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6354
6348
  return clientAction({
6355
6349
  ...args,
6356
6350
  async serverAction() {
6357
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6351
+ preventInvalidServerHandlerCall("action", route);
6358
6352
  return fetchServerAction(singleFetch);
6359
6353
  }
6360
6354
  });
@@ -6376,7 +6370,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6376
6370
  lazyRoute.loader = (args, singleFetch) => clientLoader({
6377
6371
  ...args,
6378
6372
  async serverLoader() {
6379
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6373
+ preventInvalidServerHandlerCall("loader", route);
6380
6374
  return fetchServerLoader(singleFetch);
6381
6375
  }
6382
6376
  });
@@ -6386,7 +6380,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6386
6380
  lazyRoute.action = (args, singleFetch) => clientAction({
6387
6381
  ...args,
6388
6382
  async serverAction() {
6389
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6383
+ preventInvalidServerHandlerCall("action", route);
6390
6384
  return fetchServerAction(singleFetch);
6391
6385
  }
6392
6386
  });
@@ -6431,8 +6425,13 @@ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidatio
6431
6425
  needsRevalidation
6432
6426
  );
6433
6427
  }
6434
- if (!ssr && manifestRoute.id === "root" && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
6435
- return () => false;
6428
+ if (!ssr && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
6429
+ if (route.shouldRevalidate) {
6430
+ let fn = route.shouldRevalidate;
6431
+ return (opts) => fn({ ...opts, defaultShouldRevalidate: false });
6432
+ } else {
6433
+ return () => false;
6434
+ }
6436
6435
  }
6437
6436
  if (ssr && route.shouldRevalidate) {
6438
6437
  let fn = route.shouldRevalidate;
@@ -7108,7 +7107,7 @@ function mergeRefs(...refs) {
7108
7107
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7109
7108
  try {
7110
7109
  if (isBrowser) {
7111
- window.__reactRouterVersion = "7.2.0-pre.1";
7110
+ window.__reactRouterVersion = "7.2.0-pre.2";
7112
7111
  }
7113
7112
  } catch (e) {
7114
7113
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -4359,10 +4359,10 @@ function getSingleFetchDataStrategy(manifest, routeModules, ssr, getRouter) {
4359
4359
  return singleFetchActionStrategy(request, matches);
4360
4360
  }
4361
4361
  if (!ssr) {
4362
- let foundLoaderBelowRoot = matches.some(
4363
- (m) => m.route.id !== "root" && manifest.routes[m.route.id]?.hasLoader
4362
+ let foundRevalidatingServerLoader = matches.some(
4363
+ (m) => m.shouldLoad && manifest.routes[m.route.id]?.hasLoader && !manifest.routes[m.route.id]?.hasClientLoader
4364
4364
  );
4365
- if (!foundLoaderBelowRoot) {
4365
+ if (!foundRevalidatingServerLoader) {
4366
4366
  let matchesToLoad = matches.filter((m) => m.shouldLoad);
4367
4367
  let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
4368
4368
  return results.reduce(
@@ -4817,13 +4817,7 @@ function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest
4817
4817
  needsRevalidation
4818
4818
  );
4819
4819
  }
4820
- function preventInvalidServerHandlerCall(type, route, isSpaMode) {
4821
- if (isSpaMode) {
4822
- let fn = type === "action" ? "serverAction()" : "serverLoader()";
4823
- let msg = `You cannot call ${fn} in SPA Mode (routeId: "${route.id}")`;
4824
- console.error(msg);
4825
- throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
4826
- }
4820
+ function preventInvalidServerHandlerCall(type, route) {
4827
4821
  if (type === "loader" && !route.hasLoader || type === "action" && !route.hasAction) {
4828
4822
  let fn = type === "action" ? "serverAction()" : "serverLoader()";
4829
4823
  let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
@@ -4917,7 +4911,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
4917
4911
  request,
4918
4912
  params,
4919
4913
  async serverLoader() {
4920
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
4914
+ preventInvalidServerHandlerCall("loader", route);
4921
4915
  if (isHydrationRequest) {
4922
4916
  if (hasInitialData) {
4923
4917
  return initialData;
@@ -4956,7 +4950,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
4956
4950
  request,
4957
4951
  params,
4958
4952
  async serverAction() {
4959
- preventInvalidServerHandlerCall("action", route, isSpaMode);
4953
+ preventInvalidServerHandlerCall("action", route);
4960
4954
  return fetchServerAction(singleFetch);
4961
4955
  }
4962
4956
  });
@@ -4978,7 +4972,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
4978
4972
  return clientLoader({
4979
4973
  ...args,
4980
4974
  async serverLoader() {
4981
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
4975
+ preventInvalidServerHandlerCall("loader", route);
4982
4976
  return fetchServerLoader(singleFetch);
4983
4977
  }
4984
4978
  });
@@ -5003,7 +4997,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
5003
4997
  return clientAction({
5004
4998
  ...args,
5005
4999
  async serverAction() {
5006
- preventInvalidServerHandlerCall("action", route, isSpaMode);
5000
+ preventInvalidServerHandlerCall("action", route);
5007
5001
  return fetchServerAction(singleFetch);
5008
5002
  }
5009
5003
  });
@@ -5025,7 +5019,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
5025
5019
  lazyRoute.loader = (args, singleFetch) => clientLoader({
5026
5020
  ...args,
5027
5021
  async serverLoader() {
5028
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
5022
+ preventInvalidServerHandlerCall("loader", route);
5029
5023
  return fetchServerLoader(singleFetch);
5030
5024
  }
5031
5025
  });
@@ -5035,7 +5029,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
5035
5029
  lazyRoute.action = (args, singleFetch) => clientAction({
5036
5030
  ...args,
5037
5031
  async serverAction() {
5038
- preventInvalidServerHandlerCall("action", route, isSpaMode);
5032
+ preventInvalidServerHandlerCall("action", route);
5039
5033
  return fetchServerAction(singleFetch);
5040
5034
  }
5041
5035
  });
@@ -5080,8 +5074,13 @@ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidatio
5080
5074
  needsRevalidation
5081
5075
  );
5082
5076
  }
5083
- if (!ssr && manifestRoute.id === "root" && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
5084
- return () => false;
5077
+ if (!ssr && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
5078
+ if (route.shouldRevalidate) {
5079
+ let fn = route.shouldRevalidate;
5080
+ return (opts) => fn({ ...opts, defaultShouldRevalidate: false });
5081
+ } else {
5082
+ return () => false;
5083
+ }
5085
5084
  }
5086
5085
  if (ssr && route.shouldRevalidate) {
5087
5086
  let fn = route.shouldRevalidate;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -25,7 +25,7 @@ import {
25
25
  matchRoutes,
26
26
  shouldHydrateRouteLoader,
27
27
  useFogOFWarDiscovery
28
- } from "./chunk-FXE4ZOSB.mjs";
28
+ } from "./chunk-ULARE4JK.mjs";
29
29
 
30
30
  // lib/dom-export/dom-router-provider.tsx
31
31
  import * as React from "react";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -5816,10 +5816,10 @@ function getSingleFetchDataStrategy(manifest, routeModules, ssr, getRouter) {
5816
5816
  return singleFetchActionStrategy(request, matches);
5817
5817
  }
5818
5818
  if (!ssr) {
5819
- let foundLoaderBelowRoot = matches.some(
5820
- (m) => m.route.id !== "root" && manifest.routes[m.route.id]?.hasLoader
5819
+ let foundRevalidatingServerLoader = matches.some(
5820
+ (m) => m.shouldLoad && manifest.routes[m.route.id]?.hasLoader && !manifest.routes[m.route.id]?.hasClientLoader
5821
5821
  );
5822
- if (!foundLoaderBelowRoot) {
5822
+ if (!foundRevalidatingServerLoader) {
5823
5823
  let matchesToLoad = matches.filter((m) => m.shouldLoad);
5824
5824
  let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
5825
5825
  return results.reduce(
@@ -6314,13 +6314,7 @@ function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest
6314
6314
  needsRevalidation
6315
6315
  );
6316
6316
  }
6317
- function preventInvalidServerHandlerCall(type, route, isSpaMode) {
6318
- if (isSpaMode) {
6319
- let fn = type === "action" ? "serverAction()" : "serverLoader()";
6320
- let msg = `You cannot call ${fn} in SPA Mode (routeId: "${route.id}")`;
6321
- console.error(msg);
6322
- throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
6323
- }
6317
+ function preventInvalidServerHandlerCall(type, route) {
6324
6318
  if (type === "loader" && !route.hasLoader || type === "action" && !route.hasAction) {
6325
6319
  let fn = type === "action" ? "serverAction()" : "serverLoader()";
6326
6320
  let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
@@ -6414,7 +6408,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6414
6408
  request,
6415
6409
  params,
6416
6410
  async serverLoader() {
6417
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6411
+ preventInvalidServerHandlerCall("loader", route);
6418
6412
  if (isHydrationRequest) {
6419
6413
  if (hasInitialData) {
6420
6414
  return initialData;
@@ -6453,7 +6447,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6453
6447
  request,
6454
6448
  params,
6455
6449
  async serverAction() {
6456
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6450
+ preventInvalidServerHandlerCall("action", route);
6457
6451
  return fetchServerAction(singleFetch);
6458
6452
  }
6459
6453
  });
@@ -6475,7 +6469,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6475
6469
  return clientLoader({
6476
6470
  ...args,
6477
6471
  async serverLoader() {
6478
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6472
+ preventInvalidServerHandlerCall("loader", route);
6479
6473
  return fetchServerLoader(singleFetch);
6480
6474
  }
6481
6475
  });
@@ -6500,7 +6494,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6500
6494
  return clientAction({
6501
6495
  ...args,
6502
6496
  async serverAction() {
6503
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6497
+ preventInvalidServerHandlerCall("action", route);
6504
6498
  return fetchServerAction(singleFetch);
6505
6499
  }
6506
6500
  });
@@ -6522,7 +6516,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6522
6516
  lazyRoute.loader = (args, singleFetch) => clientLoader({
6523
6517
  ...args,
6524
6518
  async serverLoader() {
6525
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6519
+ preventInvalidServerHandlerCall("loader", route);
6526
6520
  return fetchServerLoader(singleFetch);
6527
6521
  }
6528
6522
  });
@@ -6532,7 +6526,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6532
6526
  lazyRoute.action = (args, singleFetch) => clientAction({
6533
6527
  ...args,
6534
6528
  async serverAction() {
6535
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6529
+ preventInvalidServerHandlerCall("action", route);
6536
6530
  return fetchServerAction(singleFetch);
6537
6531
  }
6538
6532
  });
@@ -6577,8 +6571,13 @@ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidatio
6577
6571
  needsRevalidation
6578
6572
  );
6579
6573
  }
6580
- if (!ssr && manifestRoute.id === "root" && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
6581
- return () => false;
6574
+ if (!ssr && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
6575
+ if (route.shouldRevalidate) {
6576
+ let fn = route.shouldRevalidate;
6577
+ return (opts) => fn({ ...opts, defaultShouldRevalidate: false });
6578
+ } else {
6579
+ return () => false;
6580
+ }
6582
6581
  }
6583
6582
  if (ssr && route.shouldRevalidate) {
6584
6583
  let fn = route.shouldRevalidate;
@@ -7254,7 +7253,7 @@ function mergeRefs(...refs) {
7254
7253
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7255
7254
  try {
7256
7255
  if (isBrowser) {
7257
- window.__reactRouterVersion = "7.2.0-pre.1";
7256
+ window.__reactRouterVersion = "7.2.0-pre.2";
7258
7257
  }
7259
7258
  } catch (e) {
7260
7259
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -121,7 +121,7 @@ import {
121
121
  useSearchParams,
122
122
  useSubmit,
123
123
  useViewTransitionState
124
- } from "./chunk-FXE4ZOSB.mjs";
124
+ } from "./chunk-ULARE4JK.mjs";
125
125
  export {
126
126
  Await,
127
127
  BrowserRouter,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -5670,10 +5670,10 @@ function getSingleFetchDataStrategy(manifest, routeModules, ssr, getRouter) {
5670
5670
  return singleFetchActionStrategy(request, matches);
5671
5671
  }
5672
5672
  if (!ssr) {
5673
- let foundLoaderBelowRoot = matches.some(
5674
- (m) => m.route.id !== "root" && manifest.routes[m.route.id]?.hasLoader
5673
+ let foundRevalidatingServerLoader = matches.some(
5674
+ (m) => m.shouldLoad && manifest.routes[m.route.id]?.hasLoader && !manifest.routes[m.route.id]?.hasClientLoader
5675
5675
  );
5676
- if (!foundLoaderBelowRoot) {
5676
+ if (!foundRevalidatingServerLoader) {
5677
5677
  let matchesToLoad = matches.filter((m) => m.shouldLoad);
5678
5678
  let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
5679
5679
  return results.reduce(
@@ -6168,13 +6168,7 @@ function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest
6168
6168
  needsRevalidation
6169
6169
  );
6170
6170
  }
6171
- function preventInvalidServerHandlerCall(type, route, isSpaMode) {
6172
- if (isSpaMode) {
6173
- let fn = type === "action" ? "serverAction()" : "serverLoader()";
6174
- let msg = `You cannot call ${fn} in SPA Mode (routeId: "${route.id}")`;
6175
- console.error(msg);
6176
- throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
6177
- }
6171
+ function preventInvalidServerHandlerCall(type, route) {
6178
6172
  if (type === "loader" && !route.hasLoader || type === "action" && !route.hasAction) {
6179
6173
  let fn = type === "action" ? "serverAction()" : "serverLoader()";
6180
6174
  let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
@@ -6268,7 +6262,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6268
6262
  request,
6269
6263
  params,
6270
6264
  async serverLoader() {
6271
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6265
+ preventInvalidServerHandlerCall("loader", route);
6272
6266
  if (isHydrationRequest) {
6273
6267
  if (hasInitialData) {
6274
6268
  return initialData;
@@ -6307,7 +6301,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6307
6301
  request,
6308
6302
  params,
6309
6303
  async serverAction() {
6310
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6304
+ preventInvalidServerHandlerCall("action", route);
6311
6305
  return fetchServerAction(singleFetch);
6312
6306
  }
6313
6307
  });
@@ -6329,7 +6323,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6329
6323
  return clientLoader({
6330
6324
  ...args,
6331
6325
  async serverLoader() {
6332
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6326
+ preventInvalidServerHandlerCall("loader", route);
6333
6327
  return fetchServerLoader(singleFetch);
6334
6328
  }
6335
6329
  });
@@ -6354,7 +6348,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6354
6348
  return clientAction({
6355
6349
  ...args,
6356
6350
  async serverAction() {
6357
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6351
+ preventInvalidServerHandlerCall("action", route);
6358
6352
  return fetchServerAction(singleFetch);
6359
6353
  }
6360
6354
  });
@@ -6376,7 +6370,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6376
6370
  lazyRoute.loader = (args, singleFetch) => clientLoader({
6377
6371
  ...args,
6378
6372
  async serverLoader() {
6379
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6373
+ preventInvalidServerHandlerCall("loader", route);
6380
6374
  return fetchServerLoader(singleFetch);
6381
6375
  }
6382
6376
  });
@@ -6386,7 +6380,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6386
6380
  lazyRoute.action = (args, singleFetch) => clientAction({
6387
6381
  ...args,
6388
6382
  async serverAction() {
6389
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6383
+ preventInvalidServerHandlerCall("action", route);
6390
6384
  return fetchServerAction(singleFetch);
6391
6385
  }
6392
6386
  });
@@ -6431,8 +6425,13 @@ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidatio
6431
6425
  needsRevalidation
6432
6426
  );
6433
6427
  }
6434
- if (!ssr && manifestRoute.id === "root" && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
6435
- return () => false;
6428
+ if (!ssr && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
6429
+ if (route.shouldRevalidate) {
6430
+ let fn = route.shouldRevalidate;
6431
+ return (opts) => fn({ ...opts, defaultShouldRevalidate: false });
6432
+ } else {
6433
+ return () => false;
6434
+ }
6436
6435
  }
6437
6436
  if (ssr && route.shouldRevalidate) {
6438
6437
  let fn = route.shouldRevalidate;
@@ -7108,7 +7107,7 @@ function mergeRefs(...refs) {
7108
7107
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7109
7108
  try {
7110
7109
  if (isBrowser) {
7111
- window.__reactRouterVersion = "7.2.0-pre.1";
7110
+ window.__reactRouterVersion = "7.2.0-pre.2";
7112
7111
  }
7113
7112
  } catch (e) {
7114
7113
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -4359,10 +4359,10 @@ function getSingleFetchDataStrategy(manifest, routeModules, ssr, getRouter) {
4359
4359
  return singleFetchActionStrategy(request, matches);
4360
4360
  }
4361
4361
  if (!ssr) {
4362
- let foundLoaderBelowRoot = matches.some(
4363
- (m) => m.route.id !== "root" && manifest.routes[m.route.id]?.hasLoader
4362
+ let foundRevalidatingServerLoader = matches.some(
4363
+ (m) => m.shouldLoad && manifest.routes[m.route.id]?.hasLoader && !manifest.routes[m.route.id]?.hasClientLoader
4364
4364
  );
4365
- if (!foundLoaderBelowRoot) {
4365
+ if (!foundRevalidatingServerLoader) {
4366
4366
  let matchesToLoad = matches.filter((m) => m.shouldLoad);
4367
4367
  let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
4368
4368
  return results.reduce(
@@ -4817,13 +4817,7 @@ function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest
4817
4817
  needsRevalidation
4818
4818
  );
4819
4819
  }
4820
- function preventInvalidServerHandlerCall(type, route, isSpaMode) {
4821
- if (isSpaMode) {
4822
- let fn = type === "action" ? "serverAction()" : "serverLoader()";
4823
- let msg = `You cannot call ${fn} in SPA Mode (routeId: "${route.id}")`;
4824
- console.error(msg);
4825
- throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
4826
- }
4820
+ function preventInvalidServerHandlerCall(type, route) {
4827
4821
  if (type === "loader" && !route.hasLoader || type === "action" && !route.hasAction) {
4828
4822
  let fn = type === "action" ? "serverAction()" : "serverLoader()";
4829
4823
  let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
@@ -4917,7 +4911,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
4917
4911
  request,
4918
4912
  params,
4919
4913
  async serverLoader() {
4920
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
4914
+ preventInvalidServerHandlerCall("loader", route);
4921
4915
  if (isHydrationRequest) {
4922
4916
  if (hasInitialData) {
4923
4917
  return initialData;
@@ -4956,7 +4950,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
4956
4950
  request,
4957
4951
  params,
4958
4952
  async serverAction() {
4959
- preventInvalidServerHandlerCall("action", route, isSpaMode);
4953
+ preventInvalidServerHandlerCall("action", route);
4960
4954
  return fetchServerAction(singleFetch);
4961
4955
  }
4962
4956
  });
@@ -4978,7 +4972,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
4978
4972
  return clientLoader({
4979
4973
  ...args,
4980
4974
  async serverLoader() {
4981
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
4975
+ preventInvalidServerHandlerCall("loader", route);
4982
4976
  return fetchServerLoader(singleFetch);
4983
4977
  }
4984
4978
  });
@@ -5003,7 +4997,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
5003
4997
  return clientAction({
5004
4998
  ...args,
5005
4999
  async serverAction() {
5006
- preventInvalidServerHandlerCall("action", route, isSpaMode);
5000
+ preventInvalidServerHandlerCall("action", route);
5007
5001
  return fetchServerAction(singleFetch);
5008
5002
  }
5009
5003
  });
@@ -5025,7 +5019,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
5025
5019
  lazyRoute.loader = (args, singleFetch) => clientLoader({
5026
5020
  ...args,
5027
5021
  async serverLoader() {
5028
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
5022
+ preventInvalidServerHandlerCall("loader", route);
5029
5023
  return fetchServerLoader(singleFetch);
5030
5024
  }
5031
5025
  });
@@ -5035,7 +5029,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
5035
5029
  lazyRoute.action = (args, singleFetch) => clientAction({
5036
5030
  ...args,
5037
5031
  async serverAction() {
5038
- preventInvalidServerHandlerCall("action", route, isSpaMode);
5032
+ preventInvalidServerHandlerCall("action", route);
5039
5033
  return fetchServerAction(singleFetch);
5040
5034
  }
5041
5035
  });
@@ -5080,8 +5074,13 @@ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidatio
5080
5074
  needsRevalidation
5081
5075
  );
5082
5076
  }
5083
- if (!ssr && manifestRoute.id === "root" && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
5084
- return () => false;
5077
+ if (!ssr && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
5078
+ if (route.shouldRevalidate) {
5079
+ let fn = route.shouldRevalidate;
5080
+ return (opts) => fn({ ...opts, defaultShouldRevalidate: false });
5081
+ } else {
5082
+ return () => false;
5083
+ }
5085
5084
  }
5086
5085
  if (ssr && route.shouldRevalidate) {
5087
5086
  let fn = route.shouldRevalidate;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -25,7 +25,7 @@ import {
25
25
  matchRoutes,
26
26
  shouldHydrateRouteLoader,
27
27
  useFogOFWarDiscovery
28
- } from "./chunk-3BG6WSY4.mjs";
28
+ } from "./chunk-QRCLBIUO.mjs";
29
29
 
30
30
  // lib/dom-export/dom-router-provider.tsx
31
31
  import * as React from "react";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -5816,10 +5816,10 @@ function getSingleFetchDataStrategy(manifest, routeModules, ssr, getRouter) {
5816
5816
  return singleFetchActionStrategy(request, matches);
5817
5817
  }
5818
5818
  if (!ssr) {
5819
- let foundLoaderBelowRoot = matches.some(
5820
- (m) => m.route.id !== "root" && manifest.routes[m.route.id]?.hasLoader
5819
+ let foundRevalidatingServerLoader = matches.some(
5820
+ (m) => m.shouldLoad && manifest.routes[m.route.id]?.hasLoader && !manifest.routes[m.route.id]?.hasClientLoader
5821
5821
  );
5822
- if (!foundLoaderBelowRoot) {
5822
+ if (!foundRevalidatingServerLoader) {
5823
5823
  let matchesToLoad = matches.filter((m) => m.shouldLoad);
5824
5824
  let results = await Promise.all(matchesToLoad.map((m) => m.resolve()));
5825
5825
  return results.reduce(
@@ -6314,13 +6314,7 @@ function createClientRoutesWithHMRRevalidationOptOut(needsRevalidation, manifest
6314
6314
  needsRevalidation
6315
6315
  );
6316
6316
  }
6317
- function preventInvalidServerHandlerCall(type, route, isSpaMode) {
6318
- if (isSpaMode) {
6319
- let fn = type === "action" ? "serverAction()" : "serverLoader()";
6320
- let msg = `You cannot call ${fn} in SPA Mode (routeId: "${route.id}")`;
6321
- console.error(msg);
6322
- throw new ErrorResponseImpl(400, "Bad Request", new Error(msg), true);
6323
- }
6317
+ function preventInvalidServerHandlerCall(type, route) {
6324
6318
  if (type === "loader" && !route.hasLoader || type === "action" && !route.hasAction) {
6325
6319
  let fn = type === "action" ? "serverAction()" : "serverLoader()";
6326
6320
  let msg = `You are trying to call ${fn} on a route that does not have a server ${type} (routeId: "${route.id}")`;
@@ -6414,7 +6408,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6414
6408
  request,
6415
6409
  params,
6416
6410
  async serverLoader() {
6417
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6411
+ preventInvalidServerHandlerCall("loader", route);
6418
6412
  if (isHydrationRequest) {
6419
6413
  if (hasInitialData) {
6420
6414
  return initialData;
@@ -6453,7 +6447,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6453
6447
  request,
6454
6448
  params,
6455
6449
  async serverAction() {
6456
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6450
+ preventInvalidServerHandlerCall("action", route);
6457
6451
  return fetchServerAction(singleFetch);
6458
6452
  }
6459
6453
  });
@@ -6475,7 +6469,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6475
6469
  return clientLoader({
6476
6470
  ...args,
6477
6471
  async serverLoader() {
6478
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6472
+ preventInvalidServerHandlerCall("loader", route);
6479
6473
  return fetchServerLoader(singleFetch);
6480
6474
  }
6481
6475
  });
@@ -6500,7 +6494,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6500
6494
  return clientAction({
6501
6495
  ...args,
6502
6496
  async serverAction() {
6503
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6497
+ preventInvalidServerHandlerCall("action", route);
6504
6498
  return fetchServerAction(singleFetch);
6505
6499
  }
6506
6500
  });
@@ -6522,7 +6516,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6522
6516
  lazyRoute.loader = (args, singleFetch) => clientLoader({
6523
6517
  ...args,
6524
6518
  async serverLoader() {
6525
- preventInvalidServerHandlerCall("loader", route, isSpaMode);
6519
+ preventInvalidServerHandlerCall("loader", route);
6526
6520
  return fetchServerLoader(singleFetch);
6527
6521
  }
6528
6522
  });
@@ -6532,7 +6526,7 @@ function createClientRoutes(manifest, routeModulesCache, initialState, ssr, isSp
6532
6526
  lazyRoute.action = (args, singleFetch) => clientAction({
6533
6527
  ...args,
6534
6528
  async serverAction() {
6535
- preventInvalidServerHandlerCall("action", route, isSpaMode);
6529
+ preventInvalidServerHandlerCall("action", route);
6536
6530
  return fetchServerAction(singleFetch);
6537
6531
  }
6538
6532
  });
@@ -6577,8 +6571,13 @@ function getShouldRevalidateFunction(route, manifestRoute, ssr, needsRevalidatio
6577
6571
  needsRevalidation
6578
6572
  );
6579
6573
  }
6580
- if (!ssr && manifestRoute.id === "root" && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
6581
- return () => false;
6574
+ if (!ssr && manifestRoute.hasLoader && !manifestRoute.hasClientLoader) {
6575
+ if (route.shouldRevalidate) {
6576
+ let fn = route.shouldRevalidate;
6577
+ return (opts) => fn({ ...opts, defaultShouldRevalidate: false });
6578
+ } else {
6579
+ return () => false;
6580
+ }
6582
6581
  }
6583
6582
  if (ssr && route.shouldRevalidate) {
6584
6583
  let fn = route.shouldRevalidate;
@@ -7254,7 +7253,7 @@ function mergeRefs(...refs) {
7254
7253
  var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
7255
7254
  try {
7256
7255
  if (isBrowser) {
7257
- window.__reactRouterVersion = "7.2.0-pre.1";
7256
+ window.__reactRouterVersion = "7.2.0-pre.2";
7258
7257
  }
7259
7258
  } catch (e) {
7260
7259
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -121,7 +121,7 @@ import {
121
121
  useSearchParams,
122
122
  useSubmit,
123
123
  useViewTransitionState
124
- } from "./chunk-3BG6WSY4.mjs";
124
+ } from "./chunk-QRCLBIUO.mjs";
125
125
  export {
126
126
  Await,
127
127
  BrowserRouter,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * react-router v7.2.0-pre.1
2
+ * react-router v7.2.0-pre.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-router",
3
- "version": "7.2.0-pre.1",
3
+ "version": "7.2.0-pre.2",
4
4
  "description": "Declarative routing for React",
5
5
  "keywords": [
6
6
  "react",