S
SolidJS•6mo ago
binajmen

How to Inform children of the active status of it's parent <A/>

I'm looking at something like:
<A href=".." class=".." activeClass="..">
{({ active }) =>
<span classList={{ "my-class": active }}>..</span>
}
</A>
<A href=".." class=".." activeClass="..">
{({ active }) =>
<span classList={{ "my-class": active }}>..</span>
}
</A>
2 Replies
Alex Lohr
Alex Lohr•6mo ago
That's currently not possible. You could replicate the mechanism that detected whether an anchor is active: https://github.com/solidjs/solid-router/blob/main/src/components.tsx#L50C4-L50C4 However, it would be nice to have an exported function that allows you to check whether a certain path is active in a single call.
GitHub
solid-router/src/components.tsx at main · solidjs/solid-router
A universal router for Solid inspired by Ember and React Router - solidjs/solid-router
binajmen
binajmen•6mo ago
Thank you for pointing that out. I'll post a suggestion then 🙂