Accessing context in route `head`
Is there a specific reason you can not access the route context in a route
head
?
I am passing my i18n context from the root, and it would be nice to be able to use it there to I can call i18n._("This page title")
19 Replies
genetic-orange•2w ago
you can
via match.context
foreign-sapphireOP•2w ago
Ha thank you, I missed this! The documentation around this is quite sparse
Additional related question: is there a way to add something at the end of the
title
for every page? Similar to title templates with unheadgenetic-orange•2w ago
no. you could iterate over all matches and accumulate what they provide as title
we certainly could add a higher level API for that
foreign-sapphireOP•2w ago
In my root route
head
function I assume? In which order are the head
function called for the current route?
I guess what is mostly missing is the future documentation that is refered to here: https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management#deduping 🙂genetic-orange•2w ago
In which order are the head function called for the current routeright now that order is not defined unfortunately. we'll fix this so they are run serially like beforeload
foreign-sapphireOP•2w ago
Great
Thanks a lot, and thanks a lot for Tanstack Router. I think I now have a plan to switch Mastodon to it from a very old react router version 🎉
genetic-orange•2w ago
oh wow
foreign-sapphireOP•2w ago
(and we plan to switch our data fetching layer to tanstack query in the next 12 months)
genetic-orange•2w ago
cool! let us know if there are any issues on the way
foreign-sapphireOP•2w ago
The main issue will probably be: how do you migrate a huge 8 year codebase from old react router / dirty hacks / old redux (with the container pattern) / immutable.js / very few typescript to tanstack 😄
I am starting to have a good plan for it, but I am pretty sure it will be even more complex
genetic-orange•2w ago
i fear LLMs wont be too much help there 😄
foreign-sapphireOP•2w ago
We have a no-LLM policy 🙂
(and that wont help much, the problem is more in figuring out the migration path with the 2 architectures in //)
genetic-orange•2w ago
curious why that?
not a huge fan myself of AI at the moment, at least for what we write here (library code) it's not that helpful
foreign-sapphireOP•2w ago
Ethics, + code quality
foreign-sapphireOP•2w ago
If you have pointers on how to properly manage such a view (= Tweetdeck) with Tanstack Router, that might help me.
Right now we have one column that is controlled by the path, but it is not a very good pattern and causing lot of issues

foreign-sapphireOP•2w ago
For example if I click on the first post in my left column, it will navigate to it in the last column (which is controlled by the path).
It may be much better to allow each column to navigate independently, but I have no idea how to make this work nice with the router

genetic-orange•2w ago
query params are much more flexible
i assume there is no limit to how many columns you can have?
foreign-sapphireOP•2w ago
Correct
(well, we have a maximum for performance reasons, but some people have 12 of them…)
One of my idea was to have a query param for each column, which is either empty (= display the default content) or with a reference to the specific context currently displayed (specific post, account…)
But then we also need to keep the scroll position somewhere in the column, if we navigate within each column
genetic-orange•2w ago
maybe that's already happening with scroll restoration in router
we are monitoring scroll and restoring for each scrollable element