-
-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support cloneElement
in RSC-rendered <Link />
(better compatibility with Radix Primitives & friends)
#1271
Comments
href
The following workaround seems to work for now, but the behavior of the issue still stands: 'use client';
function NavigationMenuLocalizedLink({ item }: { item: INavigationMenuItem }) {
return (
<NavigationMenuLink asChild>
<Link href={item.href}>{item.title}</Link>
</NavigationMenuLink>
);
} |
Thanks for the careful report and reproduction!
This was in fact the first time this was reported, so maybe it's a good idea to keep this open to see if more people are affected and to give visibility to the alternative you've posted. |
Yes, I'm also facing the same issue. Directly importing from |
This topic came up again in #1322 and I've added some details in #1322 (comment). Will have a look if we can improve something here. Btw. possibly a non-obtrusive workaround might be this: // components/Link.tsx
'use client';
// Re-export from the file that creates the `<Link />` component
export {Link as default} from '@/routing'; // Import the re-exported `Link`
import Link from "components/Link";
function NavigationMenuLocalizedLink({ item }: { item: INavigationMenuItem }) {
return (
<Link href={item.href} legacyBehavior passHref>
<NavigationMenuLink>{item.title}</NavigationMenuLink>
</Link>
);
} I think this should work as expected with Radix Primitives & friends. EDIT: Asked the Radix team here about an alternative implementation that would work with RSC: radix-ui/primitives#2537 (comment). |
cloneElement
in RSC-rendered <Link />
(better compatibility with Radix Primitives & friends)
It seems like Radix Primitives will switch to a new API eventually that does not require |
Description
I'm trying to use shadcn NavigationMenu together with the next-intl link, using legacyBehavior+passHref but I'm getting a bunch of the following warnings:
Usage
Tracing back the issue, it looks like nextjs doesn't like setting the
onClick
property, whenlegacyBehavior
is set.next-intl/packages/next-intl/src/navigation/shared/BaseLink.tsx
Line 76 in ed4681f
Verifications
Mandatory reproduction URL
https://github.com/mschinis/next-intl-bug-repro-app-router
Reproduction description
Steps to reproduce:
Expected behaviour
Expected behavior is to not have any warnings.
The text was updated successfully, but these errors were encountered: