Closed MeesEgberts closed 3 weeks ago
This issue was discussed before in https://github.com/amannn/next-intl/issues/665 and https://github.com/amannn/next-intl/issues/1271.
What causes the issue is that Radix uses cloneElement
in a component that is marked with 'use client'
. The component tries to modify the child, but in your case <Link />
is a Server Component, therefore the props can't be modified anymore in the Client Components render pass (esp. if you consider that they run on the client side).
Link
from next-intl
is currently either a Server or a Client Component, depending on the environment you're importing it from. The reason for this is that we can avoid shipping some code to the client if you're calling Link
in a Server Component.
Due to this, a possible workaround is to call Link
in a Client Component.
I'm currently working on an overhaul for the navigation APIs and will have a look at this topic to see if we can do something about this to improve the compatibility with libraries like Radix that use cloneElement
.
I'm closing this in favor of https://github.com/amannn/next-intl/issues/1271.
Description
The
Link
component fromnext-intl
is not rendering when used within a parent component that has theasChild
prop set. This issue occurs specifically when trying to use theLink
component inside aDropdownMenuItem
from shadcn/ui or@radix-ui/react-dropdown-menu
.Verifications
Mandatory reproduction URL
https://www.radix-ui.com/primitives/docs/components/dropdown-menu#dropdown-menu
Reproduction description
Expected behaviour
I've tried using the
next/link
component and it renders just fine, but here nothing gets rendered.