Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda