mirror of https://github.com/portainer/portainer
23 lines
622 B
TypeScript
23 lines
622 B
TypeScript
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>
|
|
<WrappedComponent {...props} />
|
|
</UIRouterContextComponent>
|
|
);
|
|
}
|
|
|
|
WrapperComponent.displayName = `withUIRouter(${displayName})`;
|
|
|
|
return WrapperComponent;
|
|
}
|