Files
infisical/frontend/src/components/utilities/ShouldWrapComponent.tsx
T
2025-07-02 01:16:49 +05:30

21 lines
490 B
TypeScript

import { ComponentType, ReactNode } from "react";
type ShouldWrapProps<T extends Record<string, any>> = {
children: ReactNode;
wrapper: ComponentType<T & { children: ReactNode }>;
isWrapped?: boolean;
} & T;
export const ShouldWrap = <T extends Record<string, any>>({
children,
wrapper: Wrapper,
isWrapped = false,
...wrapperProps
}: ShouldWrapProps<T>) => {
if (isWrapped) {
return <Wrapper {...(wrapperProps as any)}>{children}</Wrapper>;
}
return children;
};