import React , { ReactNode } from 'react' ; import { Node } from '../interfaces' ; export function mapChildrenToNodes ( children , cb ) { return React . Children . toArray ( children ) . reduce ( ( result , child ) => { const node = cb ( child ) ; result . push ( node ) ; return result ; } , [ ] ) as Node [ ] ; }