mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Unmount components when view is destroyed
This commit is contained in:
parent
9a520b6c29
commit
dd19ef5df4
1 changed files with 6 additions and 2 deletions
|
@ -1,13 +1,17 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
|
||||||
// TODO: Probably need to rehydrate on view restores
|
|
||||||
|
|
||||||
export default (view, params, { detail }) => {
|
export default (view, params, { detail }) => {
|
||||||
if (detail.options?.pageComponent) {
|
if (detail.options?.pageComponent) {
|
||||||
|
// Fetch and render the page component to the view
|
||||||
import(/* webpackChunkName: "[request]" */ `./pages/${detail.options.pageComponent}`)
|
import(/* webpackChunkName: "[request]" */ `./pages/${detail.options.pageComponent}`)
|
||||||
.then(({ default: component }) => {
|
.then(({ default: component }) => {
|
||||||
ReactDOM.render(React.createElement(component, params), view);
|
ReactDOM.render(React.createElement(component, params), view);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Unmount component when view is destroyed
|
||||||
|
view.addEventListener('viewdestroy', () => {
|
||||||
|
ReactDOM.unmountComponentAtNode(view);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue