import React from "react";

interface ConditionalWrapProps {
	condition: boolean;
	wrap: (children: JSX.Element) => JSX.Element;
	children: JSX.Element;
}

const ConditionalWrap: React.FC<ConditionalWrapProps> = ({condition, children, wrap}): JSX.Element =>
	condition ? React.cloneElement(wrap(children)) : children;

export default ConditionalWrap;