Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
React unable to read props.title (undefined) despite passing props as usual

Error 1

I am getting this error above but I am passing props to the component; I can't figure out what's the issue here. I have been using React for a while but I was using classes, and I wanted to try using function components too. They should be technically the same however as far as I understand, just that you don't need to use this.props and you can just access props.

I am using the components on the 'Socials' page, using the Routing method below: (I get this error on "/", where the component isn't supposed to load. I'm not sure if this is causing the error, because I have not encountered this type of issue.)

        <div className = "appBody">
    <Router basename={process.env.PUBLIC_URL}>
      <Routes>
        <Route path="/" element={Home} exact/>
        <Route path="" element={Home} exact/>
        <Route path="/About" element={Home}/>
        <Route path="/Games" element={Home} />
        <Route path="/Software" element={Home} />
        <Route path="/Art" element={Home} />
        <Route path="/Writing" element={Home} />
        <Route path="/Socials" element={Socials} />
      </Routes>
    </Router>
    </div>

Here is the component I am using:

    const SocialCard = (props) => {

    console.log(props.title);

  return (
    <Card sx={{ minWidth: 275 }}>
      <CardContent>
        {/*Add icon here later*/}
        <Typography sx={{ fontSize: 16 }} color="text.secondary" gutterBottom>
          {props.title}
        </Typography>
        <Typography variant="h5" component="div">
          {props.handle}
        </Typography>
      </CardContent>
      {props.hasLink == true &&  
      <CardActions>
        <Button size="small" onClick = {() => openURL(props.url)}>View</Button>
      </CardActions>}
    </Card>
  );
}

export default SocialCard();

Here I have passed the props to the component as an example.

 <Grid item xs={5}>
        <SocialCard title = {'email'} handle = {'example@gmail.com'} hasLink = {false}/>
      </Grid>
 <Grid item xs={5}>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Instead of export default SocialCard() I should have done it without the brackets.

Final component code:

const SocialCard = (props) => {

    console.log(props.title);

  return (
    <Card sx={{ minWidth: 275 }}>
      <CardContent>
        {/*Add icon here later*/}
        <Typography sx={{ fontSize: 16 }} color="text.secondary" gutterBottom>
          {props.title}
        </Typography>
        <Typography variant="h5" component="div">
          {props.handle}
        </Typography>
      </CardContent>
      {props.hasLink == true &&  
      <CardActions>
        <Button size="small" onClick = {() => openURL(props.url)}>View</Button>
      </CardActions>}
    </Card>
  );
}

export default SocialCard;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda