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

useQueryErrorResetBoundary.md

46 lines1.2 KB

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