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

161
Views
How to print the props value in console.log?

I am new to react I was working on simple project as my code is below I just noticed how to print the value of listItem={people} as it is passed as props in my list component i.e <List listItem={people} so I can understand it in better way that what I am getting in listItem here, I tried {console.log(listItem)} but it says undefined

    *react*
   function App() {
  const [people, setPeople] = useState(data);


  return (
    <div className="container">
      <h3>{people.length} birthdays today</h3>
      <List listItem={people} />
      
      <button onClick={() => setPeople([])}>Clear All</button>

    </div>
  );
}

export default App;
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

All the parameters that you add to a component, in the component function will be sent as an object which has as key the parameter name you choose and the value that you set to it.

In the case below, I am destructuring the object that the List Component gets as a parameter.

function List({ listItem }) {
  console.log(listItem)
  
  return <div>List Component</div>
}

Here you can find more about destructuring.

about 4 years ago · Juan Pablo Isaza Report

0

You need to retrieve the prop first, this can be done with the following code.

console.log(props.listItem)

Please refer to the React Docs

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!