Skip to content

Commit

Permalink
feat: AsyncBoundary 기본 폴백 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
2scent committed Feb 10, 2025
1 parent 94e3341 commit 7c94783
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/shared/ui/async-boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,25 @@

import { Suspense, SuspenseProps } from 'react';
import { ErrorBoundary, ErrorBoundaryPropsWithRender } from 'react-error-boundary';
import { Loading } from './loading';
import { Rejected } from './rejected';

export interface AsyncBoundaryProps extends Omit<ErrorBoundaryPropsWithRender, 'fallbackRender'> {
pendingFallback: SuspenseProps['fallback'];
rejectedFallback: ErrorBoundaryPropsWithRender['fallbackRender'];
pendingFallback?: SuspenseProps['fallback'];
rejectedFallback?: ErrorBoundaryPropsWithRender['fallbackRender'];
}

const AsyncBoundary = ({ pendingFallback, rejectedFallback, children, ...errorBoundaryProps }: AsyncBoundaryProps) => {
const AsyncBoundary = ({
pendingFallback = <Loading />,
rejectedFallback = ({ error, resetErrorBoundary }) => (
<Rejected
error={error}
onReset={resetErrorBoundary}
/>
),
children,
...errorBoundaryProps
}: AsyncBoundaryProps) => {
return (
<ErrorBoundary
fallbackRender={rejectedFallback}
Expand Down

0 comments on commit 7c94783

Please sign in to comment.