1
0
mirror of https://github.com/videojs/video.js.git synced 2025-02-08 12:05:47 +02:00

docs(react guide): update guide to prevent memory leaks when components are disposed of (#4998)

When a component is disposed of, without calling ReactDOM.unmountComponentAtNode() on the data-reactroot in the destroyed component, the React.Component and videojs.Component (here EpisodeList and vjsEpisodeList) remain in memory.

The videojs.Component should listen for its dispose event and unmount its React root in the corresponding React.Component.
This commit is contained in:
Edward Hummerston 2018-03-08 04:09:06 +11:00 committed by Gary Katsevman
parent 5d689041fb
commit 1fa9dfbee2

View File

@ -105,6 +105,11 @@ class vjsEpisodeList extends vjsComponent {
player.ready(() => {
this.mount();
});
/* Remove React root when component is destroyed */
this.on("dispose", () => {
ReactDOM.unmountComponentAtNode(this.el())
});
}
/**