1
0
Fork 0
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:
Chaim Lev-Ari 2022-08-28 04:08:41 +03:00
parent 6c34eeb2ea
commit fe2340b8a0

View file

@ -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);
}
}