mifi / react-lottie-player

Fully declarative React Lottie player
MIT License
494 stars 52 forks source link

`ref` Type incorrect #110

Closed lachieh closed 7 months ago

lachieh commented 7 months ago

Currently the type of the ref prop on the Player component is inherited from the HTMLDivElement, but in the source the Lottie instance is passed to the forwarded ref.

Type inheriting here:

https://github.com/mifi/react-lottie-player/blob/66e98a12a6cae5f3dd7eb9c3c9aa2f0482e34e76/src/index.d.ts#L10-L26

Lottie ref assigned here:

https://github.com/mifi/react-lottie-player/blob/66e98a12a6cae5f3dd7eb9c3c9aa2f0482e34e76/src/makeLottiePlayer.js#L66-L70

I am happy to assist with correcting this by exposing the animElementRef prop and correcting the types for both if a PR would be accepted.

mifi commented 7 months ago

pr is welcome!

mifi commented 7 months ago

although im not sure why nobody has hit this issue before

lachieh commented 7 months ago

Thanks, I'll get to that over the next couple of days.

although im not sure why nobody has hit this issue before

My guess is that you've covered the 80% use case by accepting various props, and I'm operating in the 20% use case because I need control over the Lottie instance. Multiply that with typescript usage and it's likely a pretty small number of people who have hit this.