Skip to content

Commit

Permalink
feat: export useAsyncData for component Await (#6882)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia committed May 13, 2024
1 parent bccc7db commit 4c9456f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/little-cheetahs-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@ice/runtime': patch
'@ice/app': patch
---

feat: export useAsyncData for component Await
1 change: 1 addition & 0 deletions packages/ice/src/constant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const RUNTIME_EXPORTS = [
'useNavigate',
'useNavigation',
'useRevalidator',
'useAsyncValue',
],
source: '@ice/runtime/router',
},
Expand Down
1 change: 1 addition & 0 deletions packages/runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export {
useNavigate,
useNavigation,
useRevalidator,
useAsyncValue,
} from 'react-router-dom';

export type {
Expand Down
1 change: 1 addition & 0 deletions packages/runtime/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {
useNavigate,
useNavigation,
useRevalidator,
useAsyncValue,
} from 'react-router-dom';

export { useData, useConfig } from './RouteContext.js';
3 changes: 2 additions & 1 deletion packages/runtime/src/routes.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -105,7 +106,7 @@ export function RouteErrorComponent() {
return process.env.ICE_CORE_ROUTER === 'true' ? <ErrorComponentWithRouter /> : <></>;
}

export function Await(props) {
export function Await(props: AwaitProps & { fallback: React.ReactNode }) {
return process.env.ICE_CORE_ROUTER === 'true' ? (
<Suspense fallback={props.fallback}>
<ReactRouterAwait
Expand Down

0 comments on commit 4c9456f

Please sign in to comment.