Open History to see the last commit
1---
2id: QueryErrorResetBoundary
3title: QueryErrorResetBoundary
4---
5β
6```ts
7function QueryErrorResetBoundary(props: QueryErrorResetBoundaryProps): Element;
8```
9β
10Defined in: [packages/preact-query/src/QueryErrorResetBoundary.tsx:164](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L164)
11β
12When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to
13try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can
14reset any query errors within the boundaries of the component.
15β
16## Parameters
17β
18### props
19β
20[`QueryErrorResetBoundaryProps`](../interfaces/QueryErrorResetBoundaryProps.md)
21β
22The `children` to render.
23β
24<a id="props-properties"></a>
25β
26#### `props` properties
27β
28| Property | Type | Description |
29| ------ | ------ | ------ |
30| <a id="props-property-children"></a> `children` | \| `ComponentChildren` \| [`QueryErrorResetBoundaryFunction`](../type-aliases/QueryErrorResetBoundaryFunction.md) | Either a plain node, or a function that receives the boundary's QueryErrorResetBoundaryValue and returns a node. |
31β
32## Returns
33β
34`Element`
35β
36The `children`, rendered as-is, or called with the boundary's QueryErrorResetBoundaryValue
37if `children` is a function.
38β
39## Example
40β
41```tsx
42import { useErrorBoundary } from 'preact/hooks'
43import type { ComponentChildren } from 'preact'
44import { QueryErrorResetBoundary } from '@tanstack/preact-query'
45β
46function App() {
47 return (
48 <QueryErrorResetBoundary>
49 {({ reset }) => (
50 <ErrorBoundary reset={reset}>
51 <Page />
52 </ErrorBoundary>
53 )}
54 </QueryErrorResetBoundary>
55 )
56}
57β
58function ErrorBoundary({
59 children,
60 reset,
61}: {
62 children: ComponentChildren
63 reset: () => void
64}) {
65 const [error, resetError] = useErrorBoundary(() => reset())
66β
67 if (error) {
68 return (
69 <div>
70 There was an error!
71 <button onClick={() => resetError()}>Try again</button>
72 </div>
73 )
74 }
75β
76 return children
77}
78```