import type { PropsWithoutRef , ReactElement , ReactNode } from 'react' ; import { Children , cloneElement } from 'react' ; type Callback = ( index ? : number ) => any ; param childrenProps param propsOrCallback const usePassPropsToChildren = ( childrenProps , propsOrCallback ) => { const children = Children . map ( childrenProps , ( child , index ) => cloneElement ( child as ReactElement < any > , typeof propsOrCallback === 'function' ? propsOrCallback ( index ) : propsOrCallback ) ) ; return { children } ; } ; export default usePassPropsToChildren ;