Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda