You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Route head function can still execute before loader function finishes #6221
A follow-up of PR #6093 - In certain scenarios, head function can still run before loaderData is ready, resulting in incorrect head computation, see an example below.
Your Example Website or App
n/a
Steps to Reproduce the Bug or Issue
Say we have a blog site, and accessing an article requires auth. Let's start with the user being logged out.
Visit /article/123, shows "Not found" page content, and a generic title.
Log in, and for the sake of argument, the user is redirected to /dashboard.
Click browser's "Back" button, i.e. navigate back to /article/123.
Expected behavior
Now we can see an inconsistent state: the document body shows the article content correctly, but we still get the generic title, instead of the article's title, as we expect to see.
The reason is, the head function, which is supposed to return the article title from its loaderData, runs before the loader function can actually finish, and thus, loaderData is not available at the time of execution. (On the other hand, the article content shows correctly, because Route.useLoaderData() works as expected.)
On subsequent client navigations to that route I keep getting fresh (based on the reactive useLoaderData() hook) component data, but for the head title Quote by ${loaderData?.author || "..."} I don't get the same fresh loaderData. Always just the previous navigation loaderData. Head title is always lagging behind one loaderData run.
Activity
Dince-afk commentedon Jun 3, 2026
I am experiencing a head and component loaderData content mismatch as well in this route:
On subsequent client navigations to that route I keep getting fresh (based on the reactive useLoaderData() hook) component data, but for the head title
Quote by ${loaderData?.author || "..."}I don't get the same fresh loaderData. Always just the previous navigation loaderData. Head title is always lagging behind one loaderData run.fix: match loading
fix: match loading
fix: match loading
test: pin 24 community-reported issues fixed by the match-loading wor…
failing regressiontest for #6221
failing regressiontest for #6221
failing regressiontest for #6221