router icon indicating copy to clipboard operation
router copied to clipboard

Throwing a redirect in `beforeLoad` from __root.tsx causes a suspense error

Open samchouse opened this issue 1 year ago • 0 comments

Describe the bug

If I try to redirect a user in beforeLoad in my __root.tsx file then I get A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition. upon visiting a URL that redirects me initially.

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-uc7am2?file=src%2Froutes%2F__root.tsx

Steps to Reproduce the Bug or Issue

  1. Go to repro
  2. Open /custom/redirect in your browser

Expected behavior

It to not error.

Screenshots or Videos

No response

Platform

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

Additional context

No response

samchouse avatar Jan 30 '24 00:01 samchouse