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

QueryErrorResetBoundary.md

68 lines2.0 KB

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