Skip to content
Source
Sign inSign up
TanStack/router

`matches` in `head` property does not have `loaderData` or `context` present #7379

Closedmwkcoding(GitHub profile, opens in a new tab) opened this issue 3 comments

Which project does this relate to?

Router

Describe the bug

When navigating to a route, matches does not have contain the loaderData or context properties the first time head is called. So in my StackBlitz example, if you navigate directly to the route, the title doesn't update because loaderData is not defined.

Complete minimal reproducer

https://stackblitz.com/edit/github-qkpldktp

Steps to Reproduce the Bug

  1. Click "Open preview in new tab"
  2. Click "Connect to Project"
  3. Go to nested/even/more/nested
  4. See the console logs that loaderData is not present on any of the matches

Expected behavior

I expect that the loaderData and/or context property is present on matches from the head argument. That should also cause the title of the browser tab to become: "Nested - More - Even - Nested - Company Inc."

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.169.2
  • OS: macOS
  • Browser: Chrome
  • Browser Version: 148.0.7778.97 (Official Build) (arm64)
  • Bundler: Vite
  • Bundler Version: 8.0.12

Additional context

My use case is that I may want some value from some query data that I'm loading in the loader property to show in the title and I want to dynamically "stack" to make a sort of breadcrumb in the title.

  1. See the console logs that loaderData is not present on any of the matches

    cannot reproduce

    Image

    please be specific what you are missing

  2. schiller-manuel(GitHub profile, opens in a new tab) added labelsinformation needed

  3. @schiller-manuel the bug occurs when directly navigating to the route. Not by clicking the link to it in the app. But navigating directly.

  4. @schiller-manuel It works as expected when you navigate between routes, the issue specifically occurs on the first page "load" so to speak

  5. schiller-manuel(GitHub profile, opens in a new tab) removed labelsinformation needed

Sign in to join this conversation.