Skip to content

Commit 39ae06a

Browse files
authored
[Refactor] ErrorResetBoundary 컴포넌트에 QueryErrorResetBoundary 추가하여 에러 처리 개선 (#208)
* Refactor: ErrorResetBoundary 컴포넌트에 QueryErrorResetBoundary 추가하여 에러 처리 개선 * Refactor: ErrorFallback 컴포넌트에서 불필요한 쿼리 제거 로직 삭제
1 parent 6af0ce7 commit 39ae06a

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

apps/web/components/common/ErrorResetBoundary/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { type ReactNode, type ComponentType } from "react";
4+
import { QueryErrorResetBoundary } from "@tanstack/react-query";
45
import { ErrorBoundary, type FallbackProps } from "react-error-boundary";
56

67
interface ErrorResetBoundaryProps {
@@ -12,5 +13,13 @@ export default function ErrorResetBoundary({
1213
children,
1314
fallbackComponent: FallbackComponent,
1415
}: ErrorResetBoundaryProps): JSX.Element {
15-
return <ErrorBoundary FallbackComponent={FallbackComponent}>{children}</ErrorBoundary>;
16+
return (
17+
<QueryErrorResetBoundary>
18+
{({ reset }) => (
19+
<ErrorBoundary onReset={reset} FallbackComponent={FallbackComponent}>
20+
{children}
21+
</ErrorBoundary>
22+
)}
23+
</QueryErrorResetBoundary>
24+
);
1625
}

apps/web/components/common/Fallback/index.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
11
"use client";
22

33
import { Button } from "@ui/index";
4-
import { getQueryClient } from "@/lib/queryClient";
54

65
interface ErrorFallbackProps {
76
error: Error;
87
resetErrorBoundary: () => void;
98
}
109

1110
export default function ErrorFallback({ resetErrorBoundary }: ErrorFallbackProps): JSX.Element {
12-
const queryClient = getQueryClient();
13-
1411
const handleResetErrorBoundary = (): void => {
15-
queryClient.removeQueries();
1612
resetErrorBoundary();
1713
};
1814

0 commit comments

Comments
 (0)