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

134
Views
Pass props to a child component in React

I am creating a react functional component in which I want to display an icon.

function Item(props) {
    return ({props.icon});
}

and I display it like this -

<Item icon={<FaIcon />} />

Is there a way to pass in props to the icon from the Item component?

Something like this -

function Item(props) {
    return ({props.icon(props: {})});
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Just render it like any other component

first you need to send the raw component as a prop

<Item icon={FaIcon} />

Then you render it like a component

function Item(props) {
    return (<props.icon /* Here goes the props */ /> );
}
about 4 years ago · Juan Pablo Isaza Report

0

You could also use props.children like this:

function Item(props) {
    return (<>{ props.children }</>);
}

<Item>
   <FaIcon /* child props over here */ />
<Item>

But this only sets props from where component is called and not within the parent component Item. If you exactly want to set props within Item component the best answer would be the same as what @pablo-henrique said:

function Item(props) {
    return (<props.icon /* Here goes the props */ /> );
}

<Item icon={FaIcon} />
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!