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

133
Views
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
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!