QueryErrorResetBoundary
TheQueryErrorResetBoundary component provides a way to reset error boundaries and retry failed queries. It’s particularly useful with Suspense queries and React Error Boundaries.
Import
Props
QueryErrorResetBoundaryFunction | React.ReactNode
required
Either a render function that receives the boundary value, or regular React children.When using a render function, it receives an object with:
reset()- Function to reset the error stateclearReset()- Function to clear the reset flagisReset()- Function to check if currently in reset state
Related Hook
useQueryErrorResetBoundary
A hook to access the error reset boundary context.Examples
Basic Usage with Error Boundary
With Suspense Query
Using the Hook
Without Render Function
Multiple Queries
Nested Boundaries
Manual Reset Control
How It Works
- Creates a context that tracks reset state
- When
reset()is called, it sets an internal flag - Queries check this flag and automatically retry if it’s set
- The reset flag is cleared after queries have had a chance to retry
- Works seamlessly with React Error Boundaries’
onResetprop
Return Value (when using render function)
() => void
Call this function to reset all queries within this boundary and clear error boundaries
() => void
Manually clear the reset flag (usually done automatically)
() => boolean
Check if the boundary is currently in reset state
Notes
- Designed to work with React Error Boundaries and Suspense
- Particularly useful for Suspense queries which throw errors to error boundaries
- Multiple boundaries can be nested for granular error handling
- The
reset()function can be passed directly to Error Boundary’sonResetprop - After calling
reset(), all queries within the boundary will automatically retry - The reset state is automatically cleared after queries have retried
- Can be used with both function-as-child and normal children patterns