Skip to content

refactor: move error and not-found components to router defaults#26

Merged
amrtgaber merged 1 commit into
mainfrom
refactor/router-error-boundary-defaults
May 18, 2026
Merged

refactor: move error and not-found components to router defaults#26
amrtgaber merged 1 commit into
mainfrom
refactor/router-error-boundary-defaults

Conversation

@amrtgaber
Copy link
Copy Markdown
Contributor

Summary

  • Register the error boundary and not-found component on the router via defaultErrorComponent / defaultNotFoundComponent in main.tsx instead of errorComponent / notFoundComponent on __root.tsx. This lets the boundary catch errors thrown by the root route itself — the route-level prop can't, since the boundary is hosted inside the same route it's protecting.
  • Rename RootErrorComponentErrorBoundary so the export matches the error-boundary.tsx filename (easier IDE jump-to-symbol and grep).
  • Per-route errorComponent / notFoundComponent props still work for routes that want to override (e.g., a dashboard with inline error UI that preserves the nav).

Test plan

  • pnpm dev — app boots normally, no console errors
  • Visit a bogus path (e.g. /does-not-exist) — 404 page renders
  • Throw inside a route component — error page renders with working "Try again" / "Go home" buttons
  • pnpm build and pnpm test:run both pass

Register the error boundary and not-found component on the router via
defaultErrorComponent and defaultNotFoundComponent instead of on the
root route. This lets the boundary catch errors thrown by the root
route itself, which the route-level errorComponent cannot since it is
hosted inside the same route. Also renames RootErrorComponent to
ErrorBoundary so the export matches its filename.
@amrtgaber amrtgaber merged commit 679f0a0 into main May 18, 2026
2 checks passed
@amrtgaber amrtgaber deleted the refactor/router-error-boundary-defaults branch May 18, 2026 23:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant