Repository: remix-run/react-router
File: packages/react-router/lib/router/router.ts (TypeScript)

Code before:

      if (typeof defaultShouldRevalidate === "boolean") {
        return shouldRevalidateLoader(match, {
          ...unstable_shouldRevalidateArgs,
          defaultShouldRevalidate,
        });
      }
      return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
    },
    resolve(handlerOverride) {
      let { lazy, loader, action, middleware } = match.route;

      let callHandler =
        isUsingNewApi ||
        shouldLoad ||
        (handlerOverride &&
          !isMutationMethod(request.method) &&
          (lazy || loader));

      // If this match was marked `shouldLoad` due to a middleware and it
      // doesn't have a `loader` or `action` to run and no `lazy` to add one, then we can
      // just return undefined from the "loader" here
      let isMiddlewareOnlyRoute =
        middleware && middleware.length > 0 && !loader && !action && !lazy;

      if (callHandler && !isMiddlewareOnlyRoute) {
        return callLoaderOrAction({
          request,
          match,
          lazyHandlerPromise: _lazyPromises?.handler,
          lazyRoutePromise: _lazyPromises?.route,
          handlerOverride,
          scopedContext,
        });
      }
      return Promise.resolve({ type: ResultType.data, result: undefined });
    },
  };
}

function getTargetedDataStrategyMatches(
  mapRouteProperties: MapRoutePropertiesFunction,
  manifest: RouteManifest,
  request: Request,
  matches: AgnosticDataRouteMatch[],
  targetMatch: AgnosticDataRouteMatch,
  lazyRoutePropertiesToSkip: string[],
  scopedContext: unknown,
  shouldRevalidateArgs: DataStrategyMatch["unstable_shouldRevalidateArgs"] = null,
): DataStrategyMatch[] {
  return matches.map((match) => {

Review comment (suggestion):
```suggestion
      if (callHandler && (isMutationMethod(request.method) || !isMiddlewareOnlyRoute)) {
```

Code after:

      if (typeof defaultShouldRevalidate === "boolean") {
        return shouldRevalidateLoader(match, {
          ...unstable_shouldRevalidateArgs,
          defaultShouldRevalidate,
        });
      }
      return shouldRevalidateLoader(match, unstable_shouldRevalidateArgs);
    },
    resolve(handlerOverride) {
      let { lazy, loader, middleware } = match.route;

      let callHandler =
        isUsingNewApi ||
        shouldLoad ||
        (handlerOverride &&
          !isMutationMethod(request.method) &&
          (lazy || loader));

      // For GET requests, if this match was marked `shouldLoad` due to a
      // middleware and it doesn't have a `loader` to run and no `lazy` to add
      // one, then we can just return undefined from the "loader" here
      let isMiddlewareOnlyRoute =
        middleware && middleware.length > 0 && !loader && !lazy;

      if (
        callHandler &&
        (isMutationMethod(request.method) || !isMiddlewareOnlyRoute)
      ) {
        return callLoaderOrAction({
          request,
          match,
          lazyHandlerPromise: _lazyPromises?.handler,
          lazyRoutePromise: _lazyPromises?.route,
          handlerOverride,
          scopedContext,
        });
      }
      return Promise.resolve({ type: ResultType.data, result: undefined });
    },
  };
}

function getTargetedDataStrategyMatches(
  mapRouteProperties: MapRoutePropertiesFunction,
  manifest: RouteManifest,
  request: Request,
  matches: AgnosticDataRouteMatch[],
  targetMatch: AgnosticDataRouteMatch,
  lazyRoutePropertiesToSkip: string[],
  scopedContext: unknown,