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

185
Views
How to pass props to children with functional components?

I'm having a trouble with passing props to children in functional react. My {children} is a Details component like below:

<SidebarPage>
   {children}
</SidebarPage>
const Details = () => {}

how can I pass props in way that, I put props to {children} and I receive this props in Details component? Is this even workable?

Thanks for any help!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can pass component as prop, something like -

const SidebarPage = ({ChildComponent}) => {
  const props = { name: "X" };

  return <ChildComponent {...props} />
}

const Details = (props) => {}

<SidebarPage ChildComponent={Details} />
about 4 years ago · Juan Pablo Isaza Report

0

You could use cloneElement to add new props to a component children

const newProps = {aProp: "aProp"} ;

return (
<SidebarPage>
   {React.Children.map(props.children, child => {
     return React.cloneElement(child, {
       newProps,
    }, null)
   }
</SidebarPage>
)
about 4 years ago · Juan Pablo Isaza Report
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!