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

96
Visualizações
Adding react to html

I managed to understand how to add React to HTML, but faced a question. In tutorials I saw React is adding directly to HTML with 3 react scripts in head. In other I saw react is adding to JS file with import React from 'react' etc. When I connect js file in HTML, I write <script src="script.js" type="text/babel"></script> But if I didn't add those 3 scripts in head, but have import in js, nothing works. So, question is, how to add JS file with React with imports in js file, if it's possible.

Doesn't work with started >npx serve

Example of code that doesn't work: rh.html:

<!DOCTYPE html>
<html>
    <body>
        <div id="root"></div>

        <script src="rh.js" type="text/babel"></script>
    </body>
</html>

rh.js:

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

const element = (
    <table>
        <tr>
            <th>Name</th>
        </tr>
        <tr>
            <th>Age</th>
        </tr>
        <tr>
            <th>Region</th>
        </tr>
    </table>
)

ReactDOM.render(element, document.getElementById('root'));
about 4 years ago · Juan Pablo Isaza
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