I have a client component called Tab
:
import * as React from "react";
import type { IconType } from "react-icons";
type TabProps = {
Icon: IconType;
label: string;
isActive?: boolean;
};
export default function Tab({
Icon,
label,
isActive = false,
...props
}: TabProps) {
return (
<div>
<Icon size={20} />
{label}
</div>
);
}
Whenever I try to use this component, I get this error:
Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server"
.
Ok. I have tried wrapping the component passed via Icon
in a function that makes use of "use server"
but Next is asking me to enable some experimental flag to make use of the directive.
Is there some way to achieve what I want without going through all of this? I know this was possible in old
react. Do I need to declare the Icons as client components prior to using them or is there a better solution?