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

127
Vistas
continious functions in javascript

I'm learning redux and in this piece of code section there is a continuous function to pass the arguments. I couldn't understand the logic behinds that because i'm the PHP developer originally and it's unusual there. would you please explain and simplify that for me?

Here is my selector:

export const personBugs = userId => createSelector(
    state => state.entities.bugs,
    bugs => bugs.filter(bug => bug.userId === userId )
)

And here is my dispatch:

console.log(bugsActions.personBugs(1)(store.getState()));
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It's called a curry function or currying, this is when you want to provide one argument and at a later time provide another argument.

I am not sure why a selector is on your actions object but I'm sure that is a mistake. A selector is usually used in components to get data that the component needs but can also be used in middleware to get state info.

Here is an example of how a selector can be used in a component:

const PersonBugs = React.memo(function PersonBugs({
  personId,
}) {
  //here is a way to use the curry
  const bugs = useSelector(personBugs(personId));
  //if this wasn't a curry you have to do
  // const bugs = useSelector((state) =>
  //   personBugs(personId, state)
  // );
  //you could also not memoize the selector if you needed to
});

More information about selectors can be found here

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