justinmc / react-audio-player

A simple React wrapper on the HTML5 audio tag
MIT License
587 stars 103 forks source link

Type errors #100

Closed pt8o closed 3 years ago

pt8o commented 3 years ago

I've got a React Audio Player doing this:

onLoadedMetadata={e => {
  onSetDuration(e.currentTarget.duration);
}}

It works but TypeScript complains that duration doesn't exist on e.currentTarget.

Currently all of the events are being typed as Event. The DefinitelyTyped entry types the events as React.SyntheticEvent<HTMLAudioElement, Event>. This is probably more accurate right?

Michael-Gatmaitan commented 3 years ago

Use "onDurationChange" intead of "onLoadedMetaData" for changing duration state.