mirror of https://github.com/portainer/portainer
refactor(app): wrap react with StrictMode [EE-2023] (#6075)
parent
bcaf20caca
commit
5bd157f8fc
|
@ -0,0 +1,10 @@
|
||||||
|
import { UIRouterContextComponent } from '@uirouter/react-hybrid';
|
||||||
|
import { PropsWithChildren, StrictMode } from 'react';
|
||||||
|
|
||||||
|
export function RootProvider({ children }: PropsWithChildren<unknown>) {
|
||||||
|
return (
|
||||||
|
<StrictMode>
|
||||||
|
<UIRouterContextComponent>{children}</UIRouterContextComponent>
|
||||||
|
</StrictMode>
|
||||||
|
);
|
||||||
|
}
|
|
@ -1,7 +1,8 @@
|
||||||
import { UIRouterContextComponent } from '@uirouter/react-hybrid';
|
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { IComponentOptions, IController } from 'angular';
|
import { IComponentOptions, IController } from 'angular';
|
||||||
|
|
||||||
|
import { RootProvider } from './RootProvider';
|
||||||
|
|
||||||
function toProps(
|
function toProps(
|
||||||
propNames: string[],
|
propNames: string[],
|
||||||
controller: IController,
|
controller: IController,
|
||||||
|
@ -44,10 +45,10 @@ export function react2angular<T>(
|
||||||
this.$onChanges = () => {
|
this.$onChanges = () => {
|
||||||
const props = toProps(propNames, this, $q);
|
const props = toProps(propNames, this, $q);
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<UIRouterContextComponent>
|
<RootProvider>
|
||||||
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
||||||
<Component {...(props as T)} />
|
<Component {...(props as T)} />
|
||||||
</UIRouterContextComponent>,
|
</RootProvider>,
|
||||||
el
|
el
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue