r/reactjs • • Oct 14 '26

Shadcn components unable to render

I added a shadcn component to my vite + tailwind project with using `npx shadcn@latest add @/react-bits/Particles-JS-TW` and after importing the component

import Particles from "./components/Particles";

It shows an awesnap image, i dont know the reason, the other things were rendering good alongside but just the components showing error

6 Upvotes

16 comments sorted by

1

u/Shubham4538 Oct 15 '26

Just got the solution, removed line 864 from Particles.jsx, inside useEffect
gl.getExtension('WEBGL_lose_context')?.loseContext():

Helps the context, so when it unmounts, the context doesn't loose its contents

1

u/PrimaryFamous6139 NextJS Pages Router Oct 14 '26

Check console and terminal for the actual error. Also verify the import path and file extension. In Vite, try importing with a relative path like ./components/Particles or your configured alias, rather than /components/Particles. If it’s a React Bits component, make sure all its dependencies are installed and the component matches your React version

1

u/Shubham4538 Oct 14 '26

The comp is imported properly as it renders the canvas in the elements i checked in console, also there is no specific error showing the cause, its just the image showing instead of the component

1

u/CarNage_ZA Oct 15 '26

Ask AI?

1

u/Shubham4538 Oct 15 '26

i got all the generic answers like check the state, infinite loops, imports, installation, versions and all

1

u/CarNage_ZA Oct 15 '26

Are you copying the error and just throwing it to the AI? Use claude code, let it iterate. I will garuntee you it will find the answer.

2

u/[deleted] Oct 14 '26

[removed] — view removed comment

1

u/Shubham4538 Oct 14 '26

I cleaned up my <App /> there was no effect used before also, but i checked again, i have like a static page now, but still no solution

1

u/YmedBrei-67 Oct 16 '26

the missing dependency array thing is so easy to overlook tbh

1

u/[deleted] Oct 14 '26

[removed] — view removed comment

1

u/Shubham4538 Oct 14 '26

I guess this path confirms, and also the styles are working in console

  content: ["./src/**/*.{js,jsx,ts,tsx}"],