diff --git a/packages/react-router/lib/components.tsx b/packages/react-router/lib/components.tsx index 72a2619ac8..180ae52925 100644 --- a/packages/react-router/lib/components.tsx +++ b/packages/react-router/lib/components.tsx @@ -429,14 +429,14 @@ function DataRoutes({ return useRoutes(routes || createRoutesFromChildren(children), location); } -export interface DeferredResolveRenderFunction { - (data: Awaited): JSX.Element; +export interface DeferredResolveRenderFunction { + (data: Awaited): JSX.Element; } -export interface DeferredProps - extends Omit { - children: React.ReactNode | DeferredResolveRenderFunction; - value: Data; +export interface DeferredProps { + children: React.ReactNode | DeferredResolveRenderFunction; + value: any; + fallback: React.SuspenseProps["fallback"]; errorElement?: React.ReactNode; } @@ -444,19 +444,19 @@ export interface DeferredProps * Component to use for rendering lazily loaded data from returning deferred() * in a loader function */ -export function Deferred({ +export function Deferred({ children, value, fallback, errorElement, -}: DeferredProps) { +}: DeferredProps) { return ( {typeof children === "function" ? ( } + children={children as DeferredResolveRenderFunction} /> ) : ( children @@ -497,17 +497,16 @@ function DeferredWrapper({ children, errorElement }: DeferredWrapperProps) { return <>{children}; } -export interface ResolveDeferredProps { - children: DeferredResolveRenderFunction; +interface ResolveDeferredProps { + children: DeferredResolveRenderFunction; } /** * @private + * Indirection to leverage useDeferredData for a render-prop API on */ -export function ResolveDeferred({ - children, -}: ResolveDeferredProps) { - return children(useDeferredData()); +function ResolveDeferred({ children }: ResolveDeferredProps) { + return children(useDeferredData()); } /////////////////////////////////////////////////////////////////////////////// diff --git a/packages/react-router/lib/hooks.tsx b/packages/react-router/lib/hooks.tsx index 1bdd07487b..b11d155cf5 100644 --- a/packages/react-router/lib/hooks.tsx +++ b/packages/react-router/lib/hooks.tsx @@ -727,9 +727,9 @@ export function useRouteError() { /** * Returns the happy-path data from the nearest ancestor value */ -export function useDeferredData() { +export function useDeferredData() { let value = React.useContext(DeferredContext); - return value as Awaited; + return value; } const alreadyWarned: Record = {};