import type React from "react" ; type ReactElt = { children : ReactElt | ReactElt [ ] ; props : { children : ReactElt | ReactElt [ ] ; [ prop ] : any ; } | null ; type : React . ComponentType < any > | null ; key : string | null ; } | null ; /**
 * Traverses the tree of elements from a `React.createElement`. Notice we can't
 * traverse elements created within the children's render function since this is
 * the tree before rendering.
 */ export function traverseReactEltTree ( children , callback ) { const rec = ( elts ) => { ( Array . isArray ( elts ) ? elts : [ elts ] ) . forEach ( ( elt ) => { if ( elt ) { callback ( elt ) ; if ( elt . children ) { rec ( elt . children ) ; } if ( elt . props ?. children && elt . props . children !== elt . children ) { rec ( elt . props . children ) ; } } } ) ; } ; rec ( children as any ) ; }