Capítulo 79 de 80
Both reset the same thing — query errors within a boundary, so a "Try again" click actually retries instead of immediately re-throwing the same cached error — as a component (scopes explicitly) or a hook (scopes to the nearest QueryErrorResetBoundary, or globally if none exists).
QueryErrorResetBoundary: a render-prop component wrapping the tree — its child function receives reset, wired into an error-boundary library's (e.g. react-error-boundary) onReset prop, so clicking "Try again" both resets the error boundary and clears the underlying query's error state before re-rendering.useQueryErrorResetBoundary: the hook form of the same reset function — resets errors within the nearest ancestor QueryErrorResetBoundary, or globally across all queries if no such boundary wraps it.throwOnError query would just throw the same cached error again immediately — the boundary would never get a chance to show fresh content.const App = () => (
<QueryErrorResetBoundary>
{({ reset }) => (
<ErrorBoundary
onReset={reset}
fallbackRender={({ resetErrorBoundary }) => (
<div>There was an error! <button onClick={resetErrorBoundary}>Try again</button></div>
)}
>
<Page />
</ErrorBoundary>
)}
</QueryErrorResetBoundary>
)
useSuspenseQuery/throwOnError: true error boundary with one of these — without it, "Try again" doesn't actually retry the query.reset inline is more convenient, falling back to global scope if no boundary wraps it.