From fa350f1403703654f6aeca686fa3c37fc9a253ad Mon Sep 17 00:00:00 2001 From: ClarkXia Date: Tue, 7 May 2024 15:30:24 +0800 Subject: [PATCH] feat: export useAsyncData for component Await --- .changeset/little-cheetahs-raise.md | 6 ++++++ packages/ice/src/constant.ts | 1 + packages/runtime/src/index.ts | 1 + packages/runtime/src/router.ts | 1 + packages/runtime/src/routes.tsx | 3 ++- 5 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/little-cheetahs-raise.md diff --git a/.changeset/little-cheetahs-raise.md b/.changeset/little-cheetahs-raise.md new file mode 100644 index 0000000000..a982972ddc --- /dev/null +++ b/.changeset/little-cheetahs-raise.md @@ -0,0 +1,6 @@ +--- +'@ice/runtime': patch +'@ice/app': patch +--- + +feat: export useAsyncData for component Await diff --git a/packages/ice/src/constant.ts b/packages/ice/src/constant.ts index 29af00da67..16a8f279b0 100644 --- a/packages/ice/src/constant.ts +++ b/packages/ice/src/constant.ts @@ -51,6 +51,7 @@ export const RUNTIME_EXPORTS = [ 'useNavigate', 'useNavigation', 'useRevalidator', + 'useAsyncValue', ], source: '@ice/runtime/router', }, diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.ts index 44f7fafbf7..7371d5cefa 100644 --- a/packages/runtime/src/index.ts +++ b/packages/runtime/src/index.ts @@ -146,6 +146,7 @@ export { useNavigate, useNavigation, useRevalidator, + useAsyncValue, } from 'react-router-dom'; export type { diff --git a/packages/runtime/src/router.ts b/packages/runtime/src/router.ts index c118c62b1b..beaf72c5e5 100644 --- a/packages/runtime/src/router.ts +++ b/packages/runtime/src/router.ts @@ -8,6 +8,7 @@ export { useNavigate, useNavigation, useRevalidator, + useAsyncValue, } from 'react-router-dom'; export { useData, useConfig } from './RouteContext.js'; diff --git a/packages/runtime/src/routes.tsx b/packages/runtime/src/routes.tsx index 542cedf4cb..be0189c77a 100644 --- a/packages/runtime/src/routes.tsx +++ b/packages/runtime/src/routes.tsx @@ -1,5 +1,6 @@ import React, { Suspense } from 'react'; import { useRouteError, defer, Await as ReactRouterAwait } from 'react-router-dom'; +import type { AwaitProps } from 'react-router-dom'; // eslint-disable-next-line camelcase import type { UNSAFE_DeferredData, LoaderFunctionArgs } from '@remix-run/router'; import type { @@ -105,7 +106,7 @@ export function RouteErrorComponent() { return process.env.ICE_CORE_ROUTER === 'true' ? : <>; } -export function Await(props) { +export function Await(props: AwaitProps & { fallback: React.ReactNode }) { return process.env.ICE_CORE_ROUTER === 'true' ? (