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

206
Views
Importing ReactDOM doesn't render anything

I'm pretty new to React and I've been trying to set up a REACT app. However, I always get a blank page. Can anyone help?

HTML Code (index.html)

<html>
  <head>
    <meta charset="UTF-8" />
    <title>Home</title>
  </head>
  <body>

    <div id="root"></div>
    <script src="index.js" type="text/babel"></script>

  </body>
</html>

Javascript (index.js)

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

const page = (
  <div>
    <h1>My page</h1>
  </div>
)

ReactDOM.render(page, document.getElementById("root")); 

And yes, I am using a live server to run this code.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Browsers don't understand the text/babel MIME type.

It is there for Babel to search the DOM for scripts that it should process to convert from whatever they are (JS + JSX in this case) to JS.

You haven't included Babel in your page though.

You have a further problem in that inside your script you have import statements which depend on Node.js module resolution (and you're using a browser, not Node).


You should start at the beginning of the React guide.

You currently have an odd mix of about 20% of the quick guide to adding React to a website and 5% of using a Node.js based toolchain to transpile your code.


I recommend starting with create-react-app as it gives you a robust, performant foundation to get started with.

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!