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

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

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 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