Skip to content

Getting Invariant failed: Could not find match for from when using routeApi.useNavigate in latest router version #3679

@MTG2000

Description

@MTG2000

Which project does this relate to?

Router

Describe the bug

This bug appeared after updating to latest version (1.112.17)

Where calling the navigate function returned by routeApi.useNavigate() without a from & to params would throw an error in the console:

Uncaught Error: Invariant failed: Could not find match for from: /_post/post/$id

Check the code reproduction below

Your Example Website or App

https://stackblitz.com/edit/tanstack-router-8a83jilz?file=src%2Froutes%2F_post.post.%24id.tsx

Steps to Reproduce the Bug or Issue

Go to the /post/1 page & click on the 'Update filters' button & check the console.

Expected behavior

I would expect this to work as it used to, renavigating to the same page with the new search params or params.

Screenshots or Videos

No response

Platform

  • OS: Linux
  • Browser: Chrome
  • Version: 1.112.17

Additional context

No response

Activity

lhilgert9

lhilgert9 commented on Mar 6, 2025

@lhilgert9

I have the same problem. It should have been introduced in version 1.112.15 respectively #3671.

schiller-manuel

schiller-manuel commented on Mar 6, 2025

@schiller-manuel
Contributor

yeah the mentioned change is not working for pathless routes. need to use fullPath instead of id I think

added a commit that references this issue on Mar 6, 2025
76080f2
added a commit that references this issue on Mar 6, 2025
3372d11
added a commit that references this issue on Mar 6, 2025
c9a3278
added a commit that references this issue on Apr 16, 2025
e216934
Dharmang92

Dharmang92 commented on Apr 16, 2025

@Dharmang92

Still facing this issue in latest version 1.115 and 1.116, even after the fixes. Can you please check again?

The error is logged directly in console with no specific steps. Just use useNavigate to redirect.

schiller-manuel

schiller-manuel commented on Apr 16, 2025

@schiller-manuel
Contributor

@Dharmang92 can you please open a new issue and include a minimal complete example?

Dharmang92

Dharmang92 commented on Apr 17, 2025

@Dharmang92

@schiller-manuel Please check: #4010
I have added a reproducible in the issue. Let me know if you need more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @schiller-manuel@Dharmang92@MTG2000@lhilgert9

      Issue actions

        Getting ` Invariant failed: Could not find match for from` when using routeApi.useNavigate in latest router version · Issue #3679 · TanStack/router