Skip to content

useMatches wrong fullPath #6403

@letstri

Description

@letstri

Which project does this relate to?

Router

Describe the bug

Discrepancy between types and the true path

  const currentPagePath = useMatches({
    select: matches => (matches.map(match => match.fullPath)),
  })

  console.log(currentPagePath, currentPagePath.includes('/database/$id/table')) // Types are ok here

But in the console I see:

['/', '/', '/database/$id', '/database/$id/table/'], false

The table page has / but in types there is no any / as the end

Steps to Reproduce the Bug or Issue

  1. Create a page /src/routes/database/$id/table/index.tsx
  2. use useMatches:
    const currentPagePath = useMatches({
    select: matches => matches.map(match => match.fullPath),
    })
  3. See difference

Expected behavior

I expect to see the correct type or path

Screenshots or Videos

Image Image

Platform

  • Router / Start Version: 1.150.0

Additional context

You can use this page snippet:

import { createFileRoute, useMatches } from '@tanstack/react-router'

export const Route = createFileRoute('/database/$id/table/')({
  component: RouteComponent,
})

function RouteComponent() {
  const currentPagePath = useMatches({
    select: matches => matches.map(match => match.fullPath),
  })

  console.log(currentPagePath, currentPagePath.includes('/database/$id/table'))

  return <div>Hello "/database/$id/table/"!</div>
}

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