You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The behavior we have seen in our application that uses react-player to play videos from wistia is that our onEnded handler is invoked multiple times when it should only be invoked once.
What I think is happening
I'm not super familiar with this code, so this analysis may be incorrect:
b03365a <-- this unbinds the currentonXxxx handlers in this.props. If the onXxx handlers passed into the player as props are not memoized, as is common in a functional component with recent react versions, the old handlers remain bound (because they are different instances on each rerender) and are rebound each time the video is loaded. This results in multiple invocations of old versions of these handlers.
Current Behavior
The behavior we have seen in our application that uses react-player to play videos from wistia is that our
onEnded
handler is invoked multiple times when it should only be invoked once.What I think is happening
I'm not super familiar with this code, so this analysis may be incorrect:
b03365a <-- this unbinds the current
onXxxx
handlers inthis.props
. If theonXxx
handlers passed into the player as props are not memoized, as is common in a functional component with recent react versions, the old handlers remain bound (because they are different instances on each rerender) and are rebound each time the video is loaded. This results in multiple invocations of old versions of these handlers.The FilePlayer handles this by binding to stable functions on the component: https://github.com/CookPete/react-player/blob/master/src/players/FilePlayer.js (cf af6ed75)
The text was updated successfully, but these errors were encountered: