active nav link style

This commit is contained in:
MapleLeaf
2022-01-13 17:05:39 -06:00
parent 3efaef162b
commit b59dcc0ae7
8 changed files with 51 additions and 12 deletions

View File

@@ -0,0 +1,14 @@
import type { ReactNode } from "react"
import type { PathPattern } from "react-router"
import { useMatch } from "react-router"
export function ActiveLink({
to,
children,
}: {
to: string | PathPattern
children: (props: { active: boolean }) => ReactNode
}) {
const match = useMatch(to)
return <>{children({ active: match != undefined })}</>
}