justinmc / react-audio-player

A simple React wrapper on the HTML5 audio tag
MIT License
589 stars 104 forks source link

[Bug] audioEl.current can but not assumed to be null sometimes #93

Closed e1cb4ac37s closed 4 years ago

e1cb4ac37s commented 4 years ago

Library assumes audioEl.current to always exist, which if kinda fine in sync scenario, but in async scenario, like in setListenTrack method - rarely, but it can cause error when trying to access property of null, for example, our sentry not very often but sometimes spits Cannot read property 'currentTime' of null from aforementioned method.

Possible solution is to change parameter of ref of audioEl to HTMLAudioElement | null which seems more correct react-wise, than just HTMLAudioElement.

I'll try to fix and PR this.