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

96
Views
Passing an object to a component as prop

I'm very green at react, and I'm trying to learn the library by messing around a bit.

I'm having problems passing an object to another component. Ive created an array of objects that holds 2 string variables, 1 function and 1 int.

I'm trying to populate this inside a Grid container(Material UI framework).

When I pass the object to the other react component, it arrives as undefined. Ive tried to check if I'm passing a valid object by logging it to the console first, and it is valid.

I've also tried to refer to the properties in the component that receives the object, but the browser console throws Uncaught TypeError: Cannot read properties of undefined (reading 'person').

Does anyone know why it is being sent as undefined?

PersonList.js:

const personListe = [
    {
        firstName:'testFirstname',
        lastName:'testLastName',
        getFullName:function()
        {
            return `${this.firstName} ${this.lastName}`
        },
        age:28
    }
]

export default function PersonList() {
    
  return (
      <>
        <Grid container spacing={3}>
            {personListe.map((person) => {
                 return(
                    <Grid item xs={3} key={person.firstName}>
                    <PersonCard person={person} />   
                    </Grid>
                )
            })}
        </Grid>
    </>
  );
}

PersonCard.js:

export default function PersonCard({props})
{
    return (<>
        {console.log(props)}
    </>)
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The PersonCard Component recieves props object which includes the person object inside it.

export default function PersonCard({person})
{
    return (
      <>
        {console.log(person)}
      </>
    )
}

OR

export default function PersonCard(props)
{
    return (
      <>
        {console.log(props.person)}
      </>
    )
}
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!