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

113
Vistas
How to pass both a Function and Prop to an onClick Event in React?

I only see examples of people passing two functions but nothing on a prop and function simultaneously. Let's say I want the pass onClick={props.tested} (prop) and onClick={divTested} (function) at the same time. How do I do this??

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

0

Although I rarely see this done, you can indeed add properties to a function, and pass that "function with properties" into another function that is aware of those properties:

let functionWithProperties = function(a, b)
{
  return a + b;
}

// Add Properties to the function:
functionWithProperties.a = 5;
functionWithProperties.b = 10;

function doSomethingWithFunctionWithProperties(func)
{
  return func(func.a,func.b);
}

// Pass function with properties into another function
// that is aware of those properties:
let output = doSomethingWithFunctionWithProperties(functionWithProperties);

console.log(output); // 15

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