diff --git a/packages/next/client/components/layout-router.client.tsx b/packages/next/client/components/layout-router.client.tsx
index f79d188ef0b7..ed96a6fb390f 100644
--- a/packages/next/client/components/layout-router.client.tsx
+++ b/packages/next/client/components/layout-router.client.tsx
@@ -278,11 +278,14 @@ export function InnerLayoutRouter({
function LoadingBoundary({
children,
loading,
+ hasLoading,
}: {
children: React.ReactNode
loading?: React.ReactNode
+ hasLoading: boolean
}): JSX.Element {
- if (loading) {
+ if (hasLoading) {
+ // @ts-expect-error TODO-APP: React.Suspense fallback type is wrong
return {children}
}
@@ -450,6 +453,7 @@ export default function OuterLayoutRouter({
childProp,
error,
loading,
+ hasLoading,
template,
notFound,
rootLayoutIncluded,
@@ -460,6 +464,7 @@ export default function OuterLayoutRouter({
error: ErrorComponent
template: React.ReactNode
loading: React.ReactNode | undefined
+ hasLoading: boolean
notFound: React.ReactNode | undefined
rootLayoutIncluded: boolean
}) {
@@ -510,7 +515,7 @@ export default function OuterLayoutRouter({
key={preservedSegment}
value={
-
+
: undefined}
+ hasLoading={Boolean(Loading)}
error={ErrorComponent}
template={
@@ -982,6 +983,8 @@ export async function renderToHTMLOrFlight(
segmentPath={segmentPath}
error={ErrorComponent}
loading={Loading ? : undefined}
+ // TODO-APP: Add test for loading returning `undefined`. This currently can't be tested as the `webdriver()` tab will wait for the full page to load before returning.
+ hasLoading={Boolean(Loading)}
template={