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

151
Views
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
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!