Skip to content

Commit

Permalink
Remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Sep 6, 2024
1 parent 4b9ba88 commit 2c31dc8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 55 deletions.
2 changes: 1 addition & 1 deletion packages/remix-react/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import type {
MetaMatches,
RouteHandle,
} from "./routeModules";
import { addRevalidationParam, singleFetchUrl } from "./single-fetch";
import { singleFetchUrl } from "./single-fetch";
import { getPartialManifest, isFogOfWarEnabled } from "./fog-of-war";

function useDataRouterContext() {
Expand Down
55 changes: 1 addition & 54 deletions packages/remix-react/single-fetch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ import type {
UNSAFE_SingleFetchResults as SingleFetchResults,
} from "@remix-run/server-runtime";
import { UNSAFE_SingleFetchRedirectSymbol as SingleFetchRedirectSymbol } from "@remix-run/server-runtime";
import type {
DataRouteObject,
unstable_DataStrategyFunctionArgs as DataStrategyFunctionArgs,
} from "react-router-dom";
import type { unstable_DataStrategyFunctionArgs as DataStrategyFunctionArgs } from "react-router-dom";
import { decode } from "turbo-stream";

import { createRequestInit, isResponse } from "./data";
Expand Down Expand Up @@ -377,56 +374,6 @@ function stripIndexParam(url: URL) {
return url;
}

// Determine which routes we want to load so we can add a `?_routes` search param
// for fine-grained revalidation if necessary. There's some nuance to this decision:
//
// - The presence of `shouldRevalidate` and `clientLoader` functions are the only
// way to trigger fine-grained single fetch loader calls. without either of
// these on the route matches we just always ask for the full `.data` request.
// - If any routes have a `shouldRevalidate` or `clientLoader` then we do a
// comparison of the routes we matched and the routes we're aiming to load
// - If they don't match up, then we add the `_routes` param or fine-grained
// loading
// - This is used by the single fetch implementation above and by the
// `<PrefetchPageLinksImpl>` component so we can prefetch routes using the
// same logic
export function addRevalidationParam(
manifest: AssetsManifest,
routeModules: RouteModules,
matchedRoutes: DataRouteObject[],
loadRoutes: DataRouteObject[],
url: URL
) {
let genRouteIds = (arr: string[]) =>
arr.filter((id) => manifest.routes[id].hasLoader).join(",");

// Look at the `routeModules` for `shouldRevalidate` here instead of the manifest
// since HDR adds a wrapper for `shouldRevalidate` even if the route didn't have one
// initially.
// TODO: We probably can get rid of that wrapper once we're strictly on on
// single-fetch in v3 and just leverage a needsRevalidation data structure here
// to determine what to fetch
let needsParam = matchedRoutes.some(
(r) =>
routeModules[r.id]?.shouldRevalidate ||
manifest.routes[r.id]?.hasClientLoader
);
if (!needsParam) {
return url;
}

let matchedIds = genRouteIds(matchedRoutes.map((r) => r.id));
let loadIds = genRouteIds(
loadRoutes
.filter((r) => !manifest.routes[r.id]?.hasClientLoader)
.map((r) => r.id)
);
if (matchedIds !== loadIds) {
url.searchParams.set("_routes", loadIds);
}
return url;
}

export function singleFetchUrl(reqUrl: URL | string) {
let url =
typeof reqUrl === "string"
Expand Down

0 comments on commit 2c31dc8

Please sign in to comment.