sanity-io / sanity-mux-player

Play videos in the frontend uploaded with the MUX Sanity plugin
https://github.com/sanity-io/sanity-plugin-mux-input
21 stars 5 forks source link

Prevent infinite setState recursion #13

Closed rexxars closed 4 years ago

rexxars commented 4 years ago

When a video cannot be played, the src property never gets set on the video, which leads the componentDidUpdate to run a setState(), setting error to null. When it updates, the source is still undefined, and the setState is called again. This eventually leads to a max depth error and crashes the component.

This PR fixes the issue by checking whether or not the state would actually differ in these cases before attempting to set it.