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

54
Visualizações
Constant value is returned from the previous one

I have the following code in which the first console.log returns the current number of patients, while the console.log inside the nextPage() function returns the previous value of the number of patients.

How can I solve this so that the number of patients inside the nextPage() function is the current one?

  const pacients =
    data?.getPacients?.map((pacient) =>
      AdminPacientEntry({
        pacient,
        push,
        removerPacient: () => {
          setPacientSelectedToDelete(pacient);
        },
      })
    ) ?? [];
  
  console.log(pacients)
  
  const nextPage = (page) =>{
    console.log(pacients)
    if(pacients.length < 10){
      setCanNextPage(false)
    } else{
      setCanNextPage(true)
    }
    setCanPreviousPage(true)
    setPageNumber(page)
  }
about 4 years ago · Juan Pablo Isaza
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