Skip to main content

QueryErrorResetBoundary

The QueryErrorResetBoundary 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 state
  • clearReset() - Function to clear the reset flag
  • isReset() - Function to check if currently in reset state

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

  1. Creates a context that tracks reset state
  2. When reset() is called, it sets an internal flag
  3. Queries check this flag and automatically retry if it’s set
  4. The reset flag is cleared after queries have had a chance to retry
  5. Works seamlessly with React Error Boundaries’ onReset prop

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’s onReset prop
  • 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