router icon indicating copy to clipboard operation
router copied to clipboard

`defaultErrorComponent` default does not behave as expected

Open nstepien opened this issue 1 year ago • 0 comments

Which project does this relate to?

Router

Describe the bug

According to the docs/jsdoc, defaultErrorComponent defaults to ErrorComponent, but it doesn't behave as if ErrorComponent is set.

const router = createRouter({
  routeTree,
  defaultErrorComponent: ErrorComponent
});

Your Example Website or App

https://stackblitz.com/edit/github-svg4st?file=src%2Fmain.tsx,src%2Froutes%2Findex.tsx

Steps to Reproduce the Bug or Issue

  1. Click on the Crash the page button
  2. Notice that the outlet renders the error component
  3. Comment out the defaultErrorComponent line in main.tsx
  4. Crash the page again
  5. Notice that the whole page is now replaced with the error component, the navigation links are gone

Expected behavior

defaultErrorComponent should behave as documented, i.e. it should behave as if ErrorComponent is set. In comparison, defaultNotFoundComponent works as expected in either case. 👍

Screenshots or Videos

Image Image

Platform

  • OS: Windows
  • Browser: Chrome
  • Version: 1.57.13

Additional context

No response

nstepien avatar Sep 14 '24 16:09 nstepien