1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-19 05:19:39 +02:00
portainer/app/react-tools/withI18nSuspense.tsx

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
602 B
TypeScript
Raw Permalink Normal View History

import { ComponentType, Suspense } from 'react';
export function withI18nSuspense<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 & JSX.IntrinsicAttributes) {
return (
<Suspense fallback="Loading translations...">
<WrappedComponent {...props} />
</Suspense>
);
}
WrapperComponent.displayName = `withI18nSuspense(${displayName})`;
return WrapperComponent;
}