13 lines
316 B
TypeScript
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;
|