woocommerce/packages/js/components/src/conditional-wrapper/conditional-wrapper.tsx

13 lines
316 B
TypeScript

export type ConditionalWrapperProps< T = JSX.Element > = {
children: T;
condition: boolean;
wrapper: ( children: T ) => JSX.Element;
};
export const ConditionalWrapper = < T, >( {
condition,
wrapper,
children,
}: ConditionalWrapperProps< T > ): JSX.Element | T =>
condition ? wrapper( children ) : children;