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

157
Vistas
What is the difference between calling a function inside an arrow function on an onClick event? ReactJS

So I'm wondering why when I pass info into functions like this, why I have to make it an arrow function compared to an onClick where I just have the function name without the parenthesis. Does this also have something to do with why not calling the function inside an arrow function will just run the function on render, and then it won't run the function again when the div is clicked?

    return(
        <div className="slider">
            <div onClick={() => arrowClicked(-1)} className="slider-left-arrow slider-arrow"></div>
            <img className="slider-image-initial" alt="not found" src={imageArray[imageArrayPosition]} />
            <div onClick={() => arrowClicked(1)} className="slider-right-arrow slider-arrow"></div>
        </div>
    )

Instead of:

    return(
        <div className="slider">
            <div onClick={arrowClicked(-1)} className="slider-left-arrow slider-arrow"></div>
            <img className="slider-image-initial" alt="not found" src={imageArray[imageArrayPosition]} />
            <div onClick={arrowClicked(1)} className="slider-right-arrow slider-arrow"></div>
        </div>
    )
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