LottieFiles / lottie-react

lottie web player as a react component
https://lottiefiles.com
MIT License
717 stars 80 forks source link

fix: added new instanceloaded event #127

Closed samuelOsborne closed 1 year ago

samuelOsborne commented 1 year ago

Description

Added a new event to fire when the internal instance of the animation has been set. This is to avoid confusion with the load event, as load fires when Lottie has fired DOMLoaded, but setting the state of the react player has not yet been set, causing confusion when the player doesn't perform as expected in the user event handler.

This PR is a fix directed towards this issue

For context: https://stackoverflow.com/questions/75213109/why-lottieref-returns-only-null

Where the 'load' event was firing, but 'setState(instance)' had not yet completed, thus when we caught the 'load' event and tried player.play(), the method would fail as the instance was not yet set.

Type of change

Checklist