mirror of
https://github.com/portainer/portainer.git
synced 2025-07-24 15:59:41 +02:00
refactor(ui): remove global providers [EE-4128] (#7578)
This commit is contained in:
parent
d3f094cb18
commit
fad376b415
46 changed files with 372 additions and 214 deletions
|
@ -1,10 +1,8 @@
|
|||
import ReactDOM from 'react-dom';
|
||||
import { IComponentOptions, IController } from 'angular';
|
||||
import { Suspense } from 'react';
|
||||
import { StrictMode } from 'react';
|
||||
import _ from 'lodash';
|
||||
|
||||
import { RootProvider } from './RootProvider';
|
||||
|
||||
function toProps(
|
||||
propNames: string[],
|
||||
controller: IController,
|
||||
|
@ -54,20 +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(
|
||||
<Suspense fallback="loading translations">
|
||||
<RootProvider>
|
||||
if (!isDestroyed) {
|
||||
const props = toProps(propNames, this, $q);
|
||||
ReactDOM.render(
|
||||
<StrictMode>
|
||||
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
||||
<Component {...(props as T)} />
|
||||
</RootProvider>
|
||||
</Suspense>,
|
||||
el
|
||||
);
|
||||
</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