mirror of
https://github.com/portainer/portainer.git
synced 2025-08-10 08:15:25 +02:00
feat(ui/r2a): add is destroyed check
This commit is contained in:
parent
6c34eeb2ea
commit
fe2340b8a0
1 changed files with 20 additions and 10 deletions
|
@ -52,19 +52,29 @@ export function react2angular<T, U extends PropNames<T>[]>(
|
|||
$element: HTMLElement[],
|
||||
$q: ng.IQService
|
||||
) {
|
||||
let isDestroyed = false;
|
||||
const el = $element[0];
|
||||
this.$onChanges = () => {
|
||||
const props = toProps(propNames, this, $q);
|
||||
ReactDOM.render(
|
||||
<StrictMode>
|
||||
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
||||
<Component {...(props as T)} />
|
||||
</StrictMode>,
|
||||
|
||||
el
|
||||
);
|
||||
this.$onChanges = () => {
|
||||
if (!isDestroyed) {
|
||||
const props = toProps(propNames, this, $q);
|
||||
ReactDOM.render(
|
||||
<StrictMode>
|
||||
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
||||
<Component {...(props as T)} />
|
||||
</StrictMode>,
|
||||
|
||||
el
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
this.$onDestroy = () => {
|
||||
if (!isDestroyed) {
|
||||
isDestroyed = true;
|
||||
ReactDOM.unmountComponentAtNode(el);
|
||||
}
|
||||
};
|
||||
this.$onDestroy = () => ReactDOM.unmountComponentAtNode(el);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue