Particles JS on React nos properly working

753 Views Asked by At

I'm trying to use react-particles-js on react. When I load the page, it's not working. But when I change the color of the particle, it works! But it does not refresh the page anymore when I do changes on it. The original color was: #000, I just changed it to #000000 and started working. But when I refreshed the page, it wasn't working anymore.So I passed from the #000000 I had before to #000 again. And it worked again. So I tried to update it using window.onload(just as how I has doing it manually), but doesn't seems to be working.

window.onload = function(){
setTimeout(() => {
 particlesConfig.particles.color.value = "#000000"
console.log(
  particlesConfig.particles.color.value
)}, 1000)}

Please help. I don't really know why it only works when I change the color, but when I refresh it's not working anymore.

If you want to check my code further: code

2

There are 2 best solutions below

1
Akkarawit On

Try downgrade your react particlejs to version 3.4.1 it work for me.

0
Cian Darcy On

Particle js is deprecated now I had the exact same issue. You need to use react-tsparticles instead. it works the exact same so if you istall this and switch out your imports everything will work