videojs / video.js

Video.js - open source HTML5 video player
https://videojs.com
Other
38k stars 7.45k forks source link

React 18 StrictMode does not work with typical usage of video.js #8902

Open NikhilVideostori opened 2 days ago

NikhilVideostori commented 2 days ago

Description

video.js is not working in strict mode, when removed from my index.js file it is working fine but i can't push my code without strict mode. has anyone found any solution to it??

Reduced test case

https://codepen.io/gkatsev/pen/GwZegv?editors=1000

Steps to reproduce

video.js is working fine if i do not include my component in strict mode but if do it with strict mode it is not working. video just pops up for a split second and then nothing on the browser.

Errors

No response

What version of Video.js are you using?

8.18.1

Video.js plugins used.

No response

What browser(s) including version(s) does this occur with?

chrome

What OS(es) and version(s) does this occur with?

windows11

welcome[bot] commented 2 days ago

👋 Thanks for opening your first issue here! 👋

If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. To help make it easier for us to investigate your issue, please follow the contributing guidelines.

mister-ben commented 2 days ago

I believe [this example]](https://videojs.com/guides/react/#react-functional-component-and-useeffect-example) caters for strict mode's unmount and remount.

Alternatively, the resoreEl option was added in 7.20.0 for use cases where you need the original element to be restored when the player is disposed.