TanStack / router

🤖 Fully typesafe Router for React (and friends) w/ built-in caching, 1st class search-param APIs, client-side cache integration and isomorphic rendering.
https://tanstack.com/router
MIT License
8.12k stars 630 forks source link

notFoundError warning triggers when rendering root route #2459

Open SzymonNadbrzezny opened 1 month ago

SzymonNadbrzezny commented 1 month ago

Which project does this relate to?

Start

Describe the bug

Warning about notFoundError is shown when rendering root route and there's no defaultNotFoundComponent set, even though it renders successfully.

Error message: Warning: A notFoundError was encountered on the route with ID "__root__", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<div>Not Found<div>)

Your Example Website or App

Warning: A notFoundError was encountered on the route with ID "root", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (

Not Found
)

Steps to Reproduce the Bug or Issue

  1. Clone repo and run pnpm i
  2. Run pnpm dev
  3. Go to http://localhost:3000/
  4. Warning should appear in the server logs

Expected behavior

Warning should not appear when there's no defaultNotFoundError set.

Screenshots or Videos

Image

Platform

  • OS: Windows 10
  • Browser: Arc
  • Version: Based on Chromium version 129.0.6668.71 (Official Build) (64-bit)

Additional context

Discord thread where @schiller-manuel helped me and told me to create new issue https://discord.com/channels/719702312431386674/1238170697650405547/1291393654765650033

soyricardodev commented 4 weeks ago

I had that error my first time using start, and I solved it by adding the notFound component, but nevertheless it has been marked as a bug since it does seem to be one. I would like to work on that as my first contribution.

schiller-manuel commented 3 weeks ago

@soyricardodev adding the notFoundComponent just silences this warning. however, there shouldn't even a not found error be thrown here.