Table of Contents

Method UseErrorBoundaryReset

Namespace
Velvet
Assembly
Velvet.Docs.dll

UseErrorBoundaryReset(object?[]?, Action<ErrorBoundaryResetDetails>?)

Lets an error boundary that has caught render its children again: react-error-boundary's resetErrorBoundary as the returned ErrorBoundaryReset, its resetKeys as resetKeys and its onReset as onReset. Call it inside Render() of an [Component(IsErrorBoundary = true)] component.

public static ErrorBoundaryReset UseErrorBoundaryReset(object?[]? resetKeys = null, Action<ErrorBoundaryResetDetails>? onReset = null)

Parameters

resetKeys object[]

Values whose change resets the boundary.

onReset Action<ErrorBoundaryResetDetails>

Called before each reset, with what reset the boundary. The last committed render's is called.

Returns

ErrorBoundaryReset

The boundary's reset.

Remarks

Invoking the reset while the boundary shows its fallback calls onReset with ImperativeApi and the arguments it was invoked with, then queues the reset as a state update on the lane the call is made on; the boundary's next render on that lane renders its children instead. Invoking it while the boundary shows its children does nothing. The reset is reference-stable for the boundary's lifetime.

A render of the boundary, made while it shows a fallback for an error caught before that render, that passes resetKeys differing from those its last committed render passed — in length, or in any element compared with Object.is semantics, null reading as none — commits that fallback, then, where the boundary still holds the error, calls onReset with Keys and both key arrays and queues the reset, as react-error-boundary does from componentDidUpdate. Keys that change in the render in which a child throws do not undo that catch.

The children the fallback replaced were unmounted, so they mount again: their state starts over, and a Use<T>(Func<CancellationToken, VelvetTask<T>>, object?) among them starts its resource again. This is how a failed Use load is retried.

Exceptions

InvalidOperationException

The calling component is not an error boundary.