Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

94
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda