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

Code before:
    unstable_shouldCallHandler(defaultShouldRevalidate) {
      isUsingNewApi = true;
      if (!unstable_shouldRevalidateArgs) {
        return shouldLoad;
      }

      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,

Review comment (suggestion):
```suggestion
      // doesn't have a `loader` to run and no `lazy` to add one, then we can
```

Code after:
    unstable_shouldCallHandler(defaultShouldRevalidate) {
      isUsingNewApi = true;
      if (!unstable_shouldRevalidateArgs) {
        return shouldLoad;
      }

      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,