Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1170,26 +1170,21 @@ $ yarn add react-error-boundary
- Error가 발생하면 ErrorBoundary의 `fallbackRender` prop으로 넘긴 내용이 렌더링 되고, 그렇지 않으면 children 내용이 렌더링 된다.
- 또한, fallbackRender에 넣어주는 콜백 함수 매개 변수로 `resetErrorBoundary`를 구조 분해 할당을 통해 가져올 수 있는데, 이를 통해 모든 쿼리 에러를 `초기화` 할 수 있다. 아래 코드 같은 경우에는 button을 클릭하면 에러를 초기화하게끔 작성했다.

```jsx
```tsx
import { useQueryErrorResetBoundary } from "@tanstack/react-query"; // (*)
import { ErrorBoundary } from "react-error-boundary"; // (*)

interface Props {
interface Props extends Pick<React.ComponentProps<typeof ErrorBoundary>, 'fallbackRender'> {
children: React.ReactNode;
}

const QueryErrorBoundary = ({ children, fallback }: Props) => {
const QueryErrorBoundary = ({ children, fallbackRender }: Props) => {
const { reset } = useQueryErrorResetBoundary(); // (*)

return (
<ErrorBoundary
onReset={reset}
fallbackRender={({ resetErrorBoundary }) => (
<div>
Error!!
<button onClick={() => resetErrorBoundary()}>Try again</button>
</div>
)}
fallbackRender={fallbackRender}
>
{children}
</ErrorBoundary>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 개인적으로 너무나도 좋지만 해당 문서는 처음 tanstack query를 사용하는 사람의 기준으로 작성되야 할 것 같은데요!
기존 형태가 fallbackRender을 그래도 어떤 형태로 작성 되는지 조금 더 가이드라인이 될 것 같습니다
현재도 공식 문서를 예제를 기반으로 작성하였습니다!

https://tanstack.com/query/latest/docs/react/reference/useQueryErrorResetBoundary

Copy link
Contributor Author

@manudeli manudeli Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QueryErrorBoundary의 Props타입에는 fallback이 없지만 코드에는 fallback필드가 있어서 민재님의 의도가 QueryErrorBoundary 외부에서 ErrorBoundary.fallbackRender의 resetErrorBoundary를 사용하려는 의도로 생각했어요. 그렇다면 아예 QueryErrorBoundary의 fallback을 제거해서 의도를 더 명확히 하는 것은 어떨까요? 괜찮다면 maintainer가 수정할 수 있게 되어있는데 민재님이 그렇게 수정해주실 수 있나요?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 의도치않게 fallback이 껴있었군요 해당 부분은 제가 제거하도록 하겠습니다 감사합니다!!

Expand Down