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

QueryErrorResetBoundary.md

66 lines1.9 KB

1---
2id: QueryErrorResetBoundary
3title: QueryErrorResetBoundary
4redirect_from:
5 - framework/react/reference/QueryErrorResetBoundary
6---
7​
8```ts
9function QueryErrorResetBoundary(props: QueryErrorResetBoundaryProps): Element;
10```
11​
12Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:160](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L160)
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### props
21​
22[`QueryErrorResetBoundaryProps`](../interfaces/QueryErrorResetBoundaryProps.md)
23​
24The `children` to render.
25​
26<a id="props-properties"></a>
27​
28#### `props` properties
29​
30| Property | Type | Description |
31| ------ | ------ | ------ |
32| <a id="props-property-children"></a> `children` | \| `ReactNode` \| [`QueryErrorResetBoundaryFunction`](../type-aliases/QueryErrorResetBoundaryFunction.md) | Either a plain node, or a function that receives the boundary's QueryErrorResetBoundaryValue and returns a node. |
33​
34## Returns
35​
36`Element`
37​
38The `children`, rendered as-is, or called with the boundary's QueryErrorResetBoundaryValue
39if `children` is a function.
40​
41## Example
42​
43```tsx
44import { ErrorBoundary } from 'react-error-boundary'
45import { QueryErrorResetBoundary } from '@tanstack/react-query'
46​
47function App() {
48 return (
49 <QueryErrorResetBoundary>
50 {({ reset }) => (
51 <ErrorBoundary
52 onReset={reset}
53 fallbackRender={({ resetErrorBoundary }) => (
54 <div>
55 There was an error!
56 <button onClick={() => resetErrorBoundary()}>Try again</button>
57 </div>
58 )}
59 >
60 <Page />
61 </ErrorBoundary>
62 )}
63 </QueryErrorResetBoundary>
64 )
66```