First of all, thanks for the lib!
I'm making a collapsible navigation menu. The menu has groups with inner links.
Each group is collapsible, but should be forced open if any of the inner links is active.
With the current API I do not see a proper solution. To solve this I see two solutions.
<Match path={['/one','/two/three']}>({match}) => {....})</Match>
https://github.com/reach/router/blob/054187e17795c5c2df289109456ce42c48f49343/src/index.js#L377-L379 should be public
Would it be possible to add this to the library?
Link components already have a getProps property that receives those properties. Please refer to the example in the documentation.
@ricardobrandao, true, that's giving the info on the child level. What I need is to have a check for the parent level, to see if any of it's children is active. I do not want to use the routing hierarchy, but just match against a set of paths if any of these paths isCurrent
This would also be useful for Linaria or styled components:
import { styled } from 'linaria/react'
import { Link, LinkProps } from '@reach/router'
import React, { FC } from 'react'
const RedLinkIfCurrent: React.FC<LinkProps<any>>(Link)`
color: ${props => props.isCurrent ? 'red' : 'black' };
`
// ^-------- doesn't work
Most helpful comment
@ricardobrandao, true, that's giving the info on the child level. What I need is to have a check for the parent level, to see if any of it's children is active. I do not want to use the routing hierarchy, but just match against a set of paths if any of these paths
isCurrent