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

104
Vistas
How to have javascript inside of react.js

I am building a React.JS website and I am not entirely sure how to implement a section of JavaScript inside of my html. In normal HTML you would put the script inside of these tags:

<Script></Script>

But with react.js

function App() {
  return (
    <div>
        <button onlick='log()'>Log</button>
        <script>
            Log() = Console.log('Hello')
        </Script>
    </div>
  );
}

export default App;

Something like this will not work. How am i able to run a script this way?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Please learn how React works and how events work specifically

A basic example:

function App() {
  const log = () => console.log('Hello')

  return <button onClick={log}>Log</button>
}

export default App;
about 4 years ago · Juan Pablo Isaza Denunciar

0

try this

 function App() {
const log =()=> {console.log('Hello')}
  return (
    <div>
        <button onClick={()=>log()}>Log</button>
     
    </div>
  );
}

export default App;

more information: https://reactjs.org/docs/handling-events.html

about 4 years ago · Juan Pablo Isaza Denunciar

0

ReactJs Docs will be your friend here but basically you can run your javascript code inside your function component before your return statement

Here is a codesandbox link example

about 4 years ago · Juan Pablo Isaza Denunciar
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