shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
68.7k stars 4.07k forks source link

components are re-rendering other components #2171

Closed lfgtavora closed 6 months ago

lfgtavora commented 8 months ago

i using nextjs14 and suffering from recreations with components of shadcn, idn if i made something wrong but its bit weird.

i have a page: page.tsx (server component)

    <Test/> //client component (just printing console.log("test"))
    <ActionMenu/> //client component

inside ActionMenu.tsx, i justing returning button from shadcn:

<>
    <Button> example </Button>
</>

here the problems ocorrer: when i check browser log its intermitent, sometimes (very frequently) "test" (from ) is printing twice, but if i remove this shadcn Button component and use html default

ghost commented 8 months ago

It seems you're encountering intermittent re-renders in your Next.js application when using components from the Shadcn library. To address this, consider ensuring proper memoization of your components using React.memo. Utilize React DevTools to inspect component hierarchies and dependencies for unexpected behavior. Check the Shadcn documentation and community discussions for any specific recommendations or known issues related to re-renders. Additionally, review your Next.js configuration, upgrade dependencies to the latest versions, and isolate the problem by creating a minimal test case. If the issue persists, consider alternatives to Shadcn for problematic components. This process should help identify and resolve the root cause of the unexpected re-renders.

shadcn commented 6 months ago

This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.