Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
Is there a Way to Map Child Elements Child in react using React.Children

So I was just Trying a way to map the child component send to me but my child component have further childs in them i.e. some of the <h1></h1> tags so is there a way to further map these <h1></h1> elements in the code.

Parent Component

var ParentComp = function() {
    return (
        <div>
            <h1>Hello World</h1>
            <SomeComponent name="Dev">
                <div>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                </div>
                <div>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                </div>
                <div>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                    <h1>DEV</h1>
                </div>
            </SomeComponent>
        </div>
    )
}

ChildComponent

var SomeComponent = function(props) {
    return (
        <div>
            <h1>{props.name}</h1>            
            <div>
                {React.Children.map(props.children, function(child) {
                    return (
                        React.Children.map(function(children) {
                            return (
                                <fieldset {...children.props}>
                                    <legend>{React.cloneElement(children)}</legend>
                                </fieldset>
                            )
                        })
                    )
                })}
            </div>
        </div>
    )
}

what i want is to map those <h1></h1> tags but this code is only mapping the div.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda