import * as React from "react" ; import { buttonClick , linkClick } from "../../assets/util" ; const CloneWrapper = ( props ) => { let refArray = [ ] ; const cloneButtons = React . Children . map ( props . children , ( child , index ) => { refArray . push ( React . createRef ( ) ) ; return React . isValidElement ( child ) ? React . cloneElement ( child as React . ReactElement , { onClick : child . type === "a" ? ( e ) => linkClick ( e , refArray , index ) : ( e ) => buttonClick ( e , refArray , index ) , ref : refArray [ index ] , } ) : null ; } ) ; return < React . Fragment > { cloneButtons } < /React.Fragment>; } ; export default CloneWrapper ;