Compound Pattern in Nextjs 14 doesn't work
Answered
David posted this in #help-forum
DavidOP
Hi, I want to create ToolTip component to use like this
So I followed this guide: https://www.patterns.dev/react/compound-pattern
I already add "use client" for every component
There is no development error
But Nextjs said that
<ToolTip>
<ToolTip.Button>
button
</ToolTip.Button>
<ToolTip.Content>
content
</ToolTip.Content>
</ToolTip>// index.tsx
const ToolTip = () => {
return (
/* context and children */
)
}
ToolTip.Button = ToolTipButton
ToolTip.Content = ToolTipContent
export default ToolTipSo I followed this guide: https://www.patterns.dev/react/compound-pattern
I already add "use client" for every component
There is no development error
But Nextjs said that
Error: Unsupported Server Component type: undefined. What's wrong?Answered by David
Oh, I got it. I have to add "use client" into the component where I use this component.
2 Replies
DavidOP
Oh, I got it. I have to add "use client" into the component where I use this component.
Answer
American Wirehair
I found same problem and solutions, but Why should it be?
Does server cannot understand compound patterns?
Does server cannot understand compound patterns?