1

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

EDev
  • 400
  • 3
  • 10

2 Answers2

1

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

Cian Darcy
  • 57
  • 6
0

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

Akkarawit
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 04 '21 at 14:42