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

161
Vistas
How to export a React component as an embeddable script tag in vanilla HTML,CSS and JS

Imagine I have the following React Component

import { useEffect } from "react"

export default function AwesomeHelloWorld(props) {

    useEffect(() => {
        let targetDiv = document.getElementById("hello-world-component-will-use-this-after-load");
        if (targetDiv) {
            //Do something with retrieved div
        }
    }, []);

    return (
        <div>Hello World from a React Component</div>
    )
}

How can I build it into a single helloworld.js file such that someone can easily import the script into a regular html <script/> tag for use like this

<script async type="text/javascript" src="./helloworld.js"/>

Then inside their html body, they will have a div that the generated script above will act on after page load like this

<div id="hello-world-component-will-use-this-after-load"/>

Thank you

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