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

useQueryErrorResetBoundary.md

48 lines1.2 KB

1---
2id: useQueryErrorResetBoundary
3title: useQueryErrorResetBoundary
4redirect_from:
5 - framework/react/reference/useQueryErrorResetBoundary
6---
7​
8<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
9​
10```ts
11function useQueryErrorResetBoundary(): QueryErrorResetBoundaryValue;
12```
13​
14Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:102](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L102)
15​
16This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary
17defined it will reset them globally.
18​
19## Returns
20​
21`QueryErrorResetBoundaryValue`
22​
23The boundary's QueryErrorResetBoundaryValue.
24​
25## Example
26​
27```tsx
28import { ErrorBoundary } from 'react-error-boundary'
29import { useQueryErrorResetBoundary } from '@tanstack/react-query'
30​
31function App({ children }: { children: React.ReactNode }) {
32 const { reset } = useQueryErrorResetBoundary()
33​
34 return (
35 <ErrorBoundary
36 onReset={reset}
37 fallbackRender={({ resetErrorBoundary }) => (
38 <div>
39 There was an error!
40 <button onClick={() => resetErrorBoundary()}>Try again</button>
41 </div>
42 )}
43 >
44 {children}
45 </ErrorBoundary>
46 )
48```