Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

QueryErrorResetBoundary.md

56 lines1.5 KB

1---
2id: QueryErrorResetBoundary
3title: QueryErrorResetBoundary
4redirect_from:
5 - framework/react/reference/QueryErrorResetBoundary
6---
7​
8```ts
9function QueryErrorResetBoundary(__namedParameters: QueryErrorResetBoundaryProps): Element;
10```
11​
12Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:136](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L136)
13​
14When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to
15try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can
16reset any query errors within the boundaries of the component.
17​
18## Parameters
19​
20### \_\_namedParameters
21​
22[`QueryErrorResetBoundaryProps`](../interfaces/QueryErrorResetBoundaryProps.md)
23​
24## Returns
25​
26`Element`
27​
28The `children`, rendered as-is, or called with the boundary's QueryErrorResetBoundaryValue
29if `children` is a function.
30​
31## Example
32​
33```tsx
34import { ErrorBoundary } from 'react-error-boundary'
35import { QueryErrorResetBoundary } from '@tanstack/react-query'
36​
37function App() {
38 return (
39 <QueryErrorResetBoundary>
40 {({ reset }) => (
41 <ErrorBoundary
42 onReset={reset}
43 fallbackRender={({ resetErrorBoundary }) => (
44 <div>
45 There was an error!
46 <button onClick={() => resetErrorBoundary()}>Try again</button>
47 </div>
48 )}
49 >
50 <Page />
51 </ErrorBoundary>
52 )}
53 </QueryErrorResetBoundary>
54 )
56```