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

128
Views
React will not render to screen

I am trying to test my React to make sure it can render but for some reason it will not work. I am using npx create-react-app to create my app. Please help

JavaScript:

import React from "react"
import ReactDOM from "react-dom"

const app = () => {
  return (
    <div>
      <h1>Hello World</h1>
    </div>
  )
}
        
ReactDOM.render(app(), document.getElementById("root"))

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="index.js"></script>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"> 
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
    <title>React App</title>
</head>
<body>
    <div id="root"></div>
</body>
</html>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Instead of ReactDOM.render(app()... should be ReactDOM.render(<App>, because you want to render a component not a function,

Also as you mentioned you are using create-react-app, the default imports are these:

import React from 'react';
import ReactDOM from 'react-dom/client';

Which means you need to update your ReactDOM import

Note: every component should start with capital letter, so change const app to const App


Here is a snippet with the changes:

import React from "react"
import ReactDOM from "react-dom/client"

const App = () => {
  return (
    <div>
      <h1>Hello World</h1>
    </div>
  )
}
        
ReactDOM.render(<App/>, document.getElementById("root"))
about 4 years ago · Juan Pablo Isaza Report

0

already answered but comments should help to understand

import React from "react"
    import ReactDOM from "react-dom"
    
// component name should start with uppercase
    const App = () => {
      return (
        <div>
          <h1>Hello World</h1>
        </div>
      )
    }
         // render function takes a Reactelement as first parameter  
    ReactDOM.render(<App/>, document.getElementById("root"))
about 4 years ago · Juan Pablo Isaza Report
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!