Skip to content

Commit 44c03c6

Browse files
authored
fix: update <Await> to accept ReactNode as result (#9896)
1 parent 7049c41 commit 44c03c6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

.changeset/light-pandas-confess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
update <Await> to accept ReactNode as children function return result

packages/react-router/lib/components.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export function Routes({
394394
}
395395

396396
export interface AwaitResolveRenderFunction {
397-
(data: Awaited<any>): React.ReactElement;
397+
(data: Awaited<any>): React.ReactNode;
398398
}
399399

400400
export interface AwaitProps {
@@ -531,10 +531,8 @@ function ResolveAwait({
531531
children: React.ReactNode | AwaitResolveRenderFunction;
532532
}) {
533533
let data = useAsyncValue();
534-
if (typeof children === "function") {
535-
return children(data);
536-
}
537-
return <>{children}</>;
534+
let toRender = typeof children === "function" ? children(data) : children;
535+
return <>{toRender}</>;
538536
}
539537

540538
///////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)