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
React: How important it is to pass the event as parameter in the callback function?
<button 
     className="delete-btn"
     onClick={(event) => props.deleteNote(event, note.id)}
>

The code above is for a button that when clicked, calls a function that is in another component and should pass note.id as its parameter.

To my understanding, when we need to pass a function with extra parameters as props, we need to pass the whole callback function as written above.

However, I tried this version of code that doesn't include the event as the parameter for the callback function, and it seems to still work. Is there an important difference between the code snippets?

<button 
     className="delete-btn"
     onClick={() => props.deleteNote(event, note.id)}
>
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It depends on whether you need to do something with the event (like getting data from it or preventing the default action) or not. This is my opinion but i like to always pass it for good measure.

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