Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!