TanStackT
TanStack2y ago
4 replies
sacred-rose

Styling parent of <Link> with active state

I'd like to style a navigation that's structured like this:
<ul>
  <li className="active">
    <Link to="/foo">...</Link>
  </li>
</ul>
How do i elegantly control the className? I was looking at comparing
/foo
withuseLocation().pathname but it's typed as
string
so maybe there's a better way.
Was this page helpful?