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:
parent
5d689041fb
commit
1fa9dfbee2
@ -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())
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user