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

136
Visualizações
How do I render a react component in an html file with as few files as possible?

I am trying to render a React component in an html file without using all too much code or too many files. The end goal is to let others render my React component in their html files with as little work for them as possible, hence the necessity for few files.

If I set up a project containing two files (index.html and index.js), one for defining the react component and another for rendering it, I do not get an error, but my component does not show up.

My files look like this:

index.html

<html>
  <head>
    <title>hello world</title>
  </head>

  <body>
    <div>hello world</div>
    <p>trying to load a react component</p>
    <div id="root"></div>
  </body>
</html>

index.js

import React from "react";
import { createRoot } from "react-dom/client";

const Component = () => {
  return <div>hello this is literally react. not a joke LOL</div>;
};

const root = createRoot(document.getElementById("root"));
root.render(<Component />);

When I then run the project in the browser, the react component does not load whereas all other components do laod.

What do I do?

about 4 years ago · Santiago Gelvez
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