Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get DOMException using in React #4935

Closed
zhulduz opened this issue Feb 7, 2018 · 3 comments
Closed

Get DOMException using in React #4935

zhulduz opened this issue Feb 7, 2018 · 3 comments

Comments

@zhulduz
Copy link
Contributor

zhulduz commented Feb 7, 2018

Hi!
I embed video.js in React component according to spec https://docs.videojs.com/tutorial-react.html.
After closing page with video player (I use react-router), I get an error Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node. It happens because of a method this.player.dispose()

I noticed that removing an attribute data-vjs-player from wrapper div resolves my problem.

Have you any idea how I need to fix this issue?
Thanks in advance)

@zhulduz zhulduz changed the title Get exception DOMException using in React Get DOMException using in React Feb 7, 2018
@gkatsev
Copy link
Member

gkatsev commented Feb 7, 2018

This is because calling dispose removes itself from the page. Probably not ideal but that's how it is now and we can't change it. I wonder if we should update the example to wrap the player-div in another div? Or even update it to use the video-js element.
Something like:

<div>
  <div data-vjs-player>
    <video>
  </div>
</div>
<div>
  <video-js></video-js>
</div>

This way, the outerdiv is basically the component's main element and thus when Video.js is disposed and the <div data-vjs-player> or <video-js> elements are removed it doesn't cause an issue.

Would you be able to give this a try and if it works, make a PR to fix the doc?

@zhulduz
Copy link
Contributor Author

zhulduz commented Feb 13, 2018

Sorry for the delay. Both methods work correctly! Thanks)

I guess I will manage to make PR with fixed docs)

zhulduz added a commit to zhulduz/video.js that referenced this issue Feb 13, 2018
@dylanjha
Copy link
Contributor

This was tripping me up too. Thank you for posting the solution and updating the docs @zhulduz

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants