Video.js: Get DOMException using in React

Created on 7 Feb 2018  路  3Comments  路  Source: videojs/video.js

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)

Most helpful comment

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>
md5-c80d2a8564ba761e33b8a7b86c67749c


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?

All 3 comments

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>
md5-c80d2a8564ba761e33b8a7b86c67749c


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?

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

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

0xsven picture 0xsven  路  3Comments

stephanedemotte picture stephanedemotte  路  4Comments

shivamg705 picture shivamg705  路  4Comments

aagiulian picture aagiulian  路  3Comments

d3x7r0 picture d3x7r0  路  4Comments