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

86
Vistas
Calling 2 curried functions onChange

I have a checkbox which calls a curried function and works fine when changing the checkstate as below

const FirstCurriedFunc = (id) => () => {
  //does something
}

return (
   <input type="checkbox" checked={true} onChange={FirstCurriedFunc(id)} />
)

However when I try to call two curried Functions onChange neither function executes as expected even though they both work when called individually as above.

const SecondCurriedFunc = (id) => () => {
  //does something
}

const BothCurriedFuncs = (id) => () => {
  FirstCurriedFunc(id);
  SecondCurriedFunc(id);
}

return (
    <input type="checkbox" onChange={BothCurriedFuncs(id)} />  // neither function executes
);

Can anyone explain why this is/provide a way to call both functions onChange?

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

0

You have to actually invoke both functions in BothCurriedFuncs:

const BothCurriedFuncs = (id) => () => {
    FirstCurriedFunc(id)();
    SecondCurriedFunc(id)();
}

or, maybe cleaner, use a helper function to create a composition:

let compose = (...fns) => () => fns.reduceRight((x, f) => f(x), null)


const BothCurriedFuncs = (id) => compose(SecondCurriedFunc(id), FirstCurriedFunc(id))
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