cahilfoley / react-snowfall

A high performance, canvas based react component that creates a snowfall effect
https://cahilfoley.github.io/react-snowfall/
MIT License
381 stars 21 forks source link

Loading images from CDN doesn't show the images #59

Open netgfx opened 1 year ago

netgfx commented 1 year ago

Using image urls from cdn like https://phljyzcntikuxhwretud.supabase.co/storage/v1/object/public/assets/flake1.png

but it doesn't seem to work, no images appear or the default circles.

I'm creating the document images inside useEffect and changing a state variable with the array values. Is this acceptable or does it need some other way? The example on the docs is not very "React-y"

cahilfoley commented 1 year ago

I'll have to give this a test and have a look, but I suspect it's probably because the image hasn't been loaded by the time it's rendered to the offscreen canvas. This only happens once as an optimization so that might explain it.

Rather than creating the image elements in a useEffect I would recommend creating them with React and passing in a ref then using the ref to pass them into the config. I'll see if I can put together an example.