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

190
Visualizações
What is super(props) doing for my React component?

I am not great with JS and playing around with React.

The React docs located here state the following:

When implementing the constructor for a React.Component subclass, you should call super(props) before any other statement. Otherwise, this.props will be undefined in the constructor, which can lead to bugs.

My question is HOW does this actually work? What is super() doing that magically enables this.props within my constructor?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

In the documentation that you have mentioned. It is coded in ES6 standard of javascript.

So this statement

class Greeting extends React.Component

It means Greeting is inherting from React.Component, by calling super, you are actually calling the parent element with props parameter,

if you intend on using this.props inside the constructor, you have to call super(props)

Hope these links are helpful.

over 4 years ago · Santiago Trujillo 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