wufe / react-particles-js

Particles.js for React
https://rpj.bembi.dev/
MIT License
1.15k stars 106 forks source link

compatibility with Preact? #127

Closed AndreBClark closed 4 years ago

AndreBClark commented 4 years ago

I tried importing and adding the component from the minimal example:

    <Particles
      params={{
        particles: {
          color: {
            value: "#000000"
          }
        }
      }}

to a component on my preact app and it comes up blank image

is particle.js or react-particle-js not compatible with Preact? is there any other info I can provide?

matteobruni commented 4 years ago

Hello @AndreBClark,

Sorry it's the first time I've heard about Preact.

In Particles.tsx the first two lines are about React as you can see in the link below

https://github.com/Wufe/react-particles-js/blob/91226b8d23e5b9388ec2bc9a3b08737f8013f78c/src/Particles.tsx#L1

Does Preact work with these kind of requirements? The particles core it's vanilla TypeScript, no framework required so they should work. (The TypeScript library output is a window based Javascript and ES6/.d.ts files)

You can try porting the Particles.tsx in Preact to see if it's the React dependency the issue.

AndreBClark commented 4 years ago

I don't know how to do that. ordinarily. I would use preact-compat to alias react and react-dom. but it still comes up with a blank <canvas>. Preact is a lightweight alternative to react, I'm currently using for building web ads. for most things, Preact is interchangeable with react especially with the preact-compat issue, but in this case I'm not even getting an error https://preactjs.com/guide/v10/switching-to-preact

AndreBClark commented 4 years ago

Preact Compatibility is likely out of scope for this project. it probably needs it's own package. if you disagree feel free to reopen this.