import React, { useRef } from "react" import { CSSTransition } from 'react-transition-group'; export interface Props { isOpen: boolean, stayOpen?: boolean, onClose: (...args: any[]) => any, position?: "top" | "bottomRight" | "bottomLeft" | "topRight" | "topLeft", className?: string, children?: any } const Dropdown = ({ isOpen, stayOpen, onClose, position, children, className }: Props): JSX.Element => { const dropdown = useRef(null) const getChildClick = (child: any) => { return () => { if (child.props.onClick) child.props.onClick() if (!stayOpen) onClose() } } const getChildren = React.Children.map(children, child => { if (React.isValidElement(child)) { return React.cloneElement(child, { // @ts-ignore-next-line onClick: getChildClick(child) }) } return child }) return (