import React from 'react'; export function renderChildren( children: React.ReactNode, props?: (child: any, index: number) => T, Component?: typeof React.Component ) { return React.Children.map(children, (child, index) => { if (React.isValidElement(child)) { if (Component) { return ( {React.cloneElement( child as any, props ? props(child, index) : {} )} ); } return React.cloneElement( child as any, props ? props(child, index) : {} ); } return null; }); } export function isValidChild(children: React.ReactNode) { return !( typeof children === 'string' || typeof children === 'number' || typeof children === 'bigint' || typeof children === 'symbol' || typeof children === 'boolean' ); }