Skip to content

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

@mwkcoding

Description

@mwkcoding

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions