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

153
Visualizações
Properly pass an element to React for Rendering

I have the following code to create and render a React element without using JSX:

function Weekday(props) {
    return React.createElement('p', null, `Today is ${props.day}`);
}

let dayElem = React.createElement(Weekday, {day: 'Monday'});

ReactDOM.createRoot(document.getElementById('app')).render(dayElem);

This is based on a tutorial that I am following. As you can see, createElement() is being called twice above. I thought it was weird and decided to define dayElem like this:

let dayElem = Weekday({day: 'Monday'});

It still works and renders the content properly. Is there a particular reason why the tutorial did it the first way, instead of simply calling the function?

Are there any disadvantages of using the second method?

Thanks.

about 4 years ago · Juan Pablo Isaza
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