export default function (props) {
  let {
    togglePopup,
    isPopupOpen,
    removeClose,
    position,
    children,
    placement,
    getTargetRef,
    getContainerRef
  } = props;
  let popupProps = {
    togglePopup,
    isPopupOpen,
    removeClose,
    position,
    placement,
    getTargetRef,
    getContainerRef
  };

  const childrenWithProps = React.Children.map(children, (child, index) => {
    return React.cloneElement(child, popupProps);
  });
  delete childrenWithProps.children;
  return childrenWithProps;
}
