Skip to content
Source
Sign inSign up
TanStack/router

`Route.onError` return type doesn't match `Redirect` return type #2129

Send to my agent
ClosedRendez(GitHub profile, opens in a new tab) opened this issue 1 comment

Describe the bug

I think there's a regression on onError, the documentation states:

"If this function returns a redirect object, the redirect will be applied immediately." https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#onerror-property

... But the typings say otherwise:

onError?: (err: any) => void;

Your Example Website or App

https://tanstack.com/router/latest/docs/framework/react/api/router/RouteOptionsType#onerror-property

Steps to Reproduce the Bug or Issue

  1. create a Route.loader()
  2. throw inside it
  3. define Route.onError
  4. return a redirect

Expected behavior

Are we allowed to return a redirect()?

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

  1. The docs need to be updated here.

    The implementation requires that a redirect be thrown from the onError callback for it to be consumed by the handled by the router.

  2. SeanCassiere added labelsdocumentation

  3. SeanCassiere closed this

Sign in to join this conversation.