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

useQueryErrorResetBoundary.md

28 lines714 Bytes

1---
2id: useQueryErrorResetBoundary
3title: useQueryErrorResetBoundary
4---
5​
6This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary defined it will reset them globally:
7​
8```js
9import { useQueryErrorResetBoundary } from 'react-query'
10import { ErrorBoundary } from 'react-error-boundary'
11​
12const App: React.FC = () => {
13 const { reset } = useQueryErrorResetBoundary()
14 return (
15 <ErrorBoundary
16 onReset={reset}
17 fallbackRender={({ resetErrorBoundary }) => (
18 <div>
19 There was an error!
20 <Button onClick={() => resetErrorBoundary()}>Try again</Button>
21 </div>
22 )}
23 >
24 <Page />
25 </ErrorBoundary>
26 )
28```