Skip to content

Error "Invariant failed: Could not find match for from" when layout + file-based routing is used #4010

Open
@Dharmang92

Description

@Dharmang92

Which project does this relate to?

Router

Describe the bug

When trying to use the layout routing file, the routes created are correct but when trying to open one of the route using component, it fails to load or when trying to refresh the page which is already on the failed route.

Your Example Website or App

https://stackblitz.com/edit/tanstack-invariant-bug

Steps to Reproduce the Bug or Issue

  1. Click on About or Dashboard link
  2. Error is thrown

Expected behavior

I should be able to properly add a layout routing file and the nested components should work correctly.

For example below routes:

app/home
app/about
app/dashboard

I have route.tsx (default pattern for layout file) file inside app folder which contains the nav bar, then /home, /about and /dashboard should have the nav bar present in them.

Screenshots or Videos

Image

Platform

"@tanstack/react-router": "^1.116.0"
"@tanstack/router-plugin": "^1.116.1"

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions