mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +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
23
app/react-tools/withUIRouter.tsx
Normal file
23
app/react-tools/withUIRouter.tsx
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { ComponentType } from 'react';
|
||||
import { UIRouterContextComponent } from '@uirouter/react-hybrid';
|
||||
|
||||
export function withUIRouter<T>(
|
||||
WrappedComponent: ComponentType<T>
|
||||
): ComponentType<T> {
|
||||
// Try to create a nice displayName for React Dev Tools.
|
||||
const displayName =
|
||||
WrappedComponent.displayName || WrappedComponent.name || 'Component';
|
||||
|
||||
function WrapperComponent(props: T) {
|
||||
return (
|
||||
<UIRouterContextComponent>
|
||||
{/* eslint-disable-next-line react/jsx-props-no-spreading */}
|
||||
<WrappedComponent {...props} />
|
||||
</UIRouterContextComponent>
|
||||
);
|
||||
}
|
||||
|
||||
WrapperComponent.displayName = displayName;
|
||||
|
||||
return WrapperComponent;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue