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

213
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
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