isRouteErrorResponse: isRouteErrorResponse

View source: R/helpers.R

isRouteErrorResponseR Documentation

isRouteErrorResponse

Description

https://api.reactrouter.com/v7/functions/react-router.isRouteErrorResponse.html

Usage

isRouteErrorResponse()

Details

Returns a JS reference to the isRouteErrorResponse type guard. Use it inside an errorElement render callback to branch on whether the error came from a thrown Response (e.g. throw new Response(..., { status: 404 })) or from arbitrary code. Pair with useRouteError.

Calling isRouteErrorResponse() from R returns a JS expression that evaluates, in the browser, to the upstream isRouteErrorResponse function. Interpolate it inside the render string of useRouteError() as shown below.

For convenience, the same function is also reachable inside any user-authored JS string as window.jsmodule['@/reactRouter'].helpers.isRouteErrorResponse.

Value

A JS expression evaluating to the isRouteErrorResponse function reference.

Examples

## Not run: 
useRouteError(render = JS(paste0(
  "e => ", isRouteErrorResponse(),
  "(e) ? <p>HTTP {e.status}</p> : <p>Unknown error</p>"
)))

## End(Not run)


reactRouter documentation built on May 10, 2026, 5:07 p.m.