Skip to content

In Memory routers useMatchRoute does not behave as expected #1410

@DNR500

Description

@DNR500

Describe the bug

Noticed this after another fix for the routers history back and go functions (#1407)

useMatchRoute hook isn't behaving consistently between In memory router and the standard router. For the in memory router useMatchRouter wrongfully returns a match where it would behave as expected in the standard use of the router.

I've create created an example that should only show a back button when not on the home/root page

Your Example Website or App

In memory example on Codesandbox

Steps to Reproduce the Bug or Issue

In memory example on Codesandbox

  • Click on the about page - the back button should appear
  • Click back and the page should navigate to the home page and but the back isn't removed
  • Also, after clicking back any other attempts to navigate between the about page and the home page no longer remove the back button. Also after clicking back using the home and about links in the example can require two clicks

Expected behavior

Here is how it currently works on the standard router for the browser

standard router example on Codesandbox

  • Click on the about page - the back button should appear
  • Click back and the page should navigate to the home page and back button is no longer visible
  • After clicking back, navigating between the home and about sections should only require 1 click on there respective links

Screenshots or Videos

No response

Platform

  • OS: macOS 13.3.1 (22E261)
  • Browser: Chrome Version 123.0.6312.59 (Official Build) (arm64)
  • Version: @tanstack/react-router: ^1.26.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