Link isActive on parent component
I need to pass isActive to the parent component of a Link. It is described here how to do it for a child component:
https://tanstack.com/router/latest/docs/framework/react/guide/navigation#passing-isactive-to-children
But I can't seem to figure out how I could check if the link is active at the parent component. Any help greatly appreciated!
TanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.

6 Replies
exotic-emerald•11mo ago
Assuming you need it for styling purposes, active Link components are passed the
active
class so if you're using tailwind, you can do this
eastern-cyanOP•11mo ago
It's not for styling purposes. I need to pass an actual boolean prop to the parent.
exotic-emerald•11mo ago
use the
useMatches
hook theneastern-cyanOP•11mo ago
Could you help me with an example?
Like this?
exotic-emerald•11mo ago
Sorry, it was the
useMatchRoute
hook instead. So assuming you're creating a reusable link component
Or with your example
eastern-cyanOP•11mo ago
Thank you!