-
Hi, everyone. I'm using However, when I use // Working
<Menu.Item>
{({ active }) => {
return (
<a
href="/"
className={
active ? classes.linkActive : classes.linkInactive
}
>
Working
</a>
);
}}
</Menu.Item> // Not working
<Menu.Item>
{({ active }) => {
return (
<Link href="/">
<a
className={
active ? classes.linkActive : classes.linkInactive
}
>
Not working
</a>
</Link>
);
}}
</Menu.Item> // Not working
{links.map((link) => {
return (
<Menu.Item key={link.href}>
{({ active }) => {
return (
<Link href={link.href}>
<a
className={
active
? classes.linkActive
: classes.linkInactive
}
>
Also not working for {link.name}
</a>
</Link>
);
}}
</Menu.Item>
);
})} Is |
Beta Was this translation helpful? Give feedback.
Answered by
njncalub
Jun 19, 2021
Replies: 1 comment
-
Refined my search filters and found this: #145. I've updated nikosolihin's comment for TypeScript and it's now working. interface LinkWrapperProps {
active: boolean;
href: string;
children?: React.ReactNode;
}
const LinkWrapper = React.forwardRef<HTMLAnchorElement, LinkWrapperProps>(
({ href, active, children, ...props }, ref) => {
return (
<Link href={href}>
<a
ref={ref}
className={active ? classes.linkActive : classes.linkInactive}
{...props}
>
{children}
</a>
</Link>
);
}
);
LinkWrapper.displayName = 'LinkWrapper'; {links.map((link) => {
return (
<Menu.Item key={link.href}>
{({ active }) => {
return (
<LinkWrapper href={link.href} active={active}>
{link.name}
</LinkWrapper>
);
}}
</Menu.Item>
);
})} Thanks! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
njncalub
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refined my search filters and found this: #145.
I've updated nikosolihin's comment for TypeScript and it's now working.