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

73
Visualizações
Having trouble filtering react usestate hook array with strings

It just doesnt seem like any of the below solutions are working because the first addition of a COLOR doesnt show up on the same render as the 2nd Hook action .

There's definitely a solution to be had here with rerendering.

const TestArrayPush = (e) => {
      const newColor = e

      setColorArray(oldArray => [...oldArray, newColor])
        setFilteredArray(
          colorArray.filter(colors => colors == newColor)
          )
      }
<div>
                                <input
                                  type="checkbox"
                                  value="White"
                                  name="checkbox"
                                  onClick={(e) => TestArrayPush(e.target.value)}
                                  /> White
                                <input
                                  type="checkbox"
                                  value="Black"
                                  name="checkbox"
                                  onClick={(e) => TestArrayPush(e.target.value)}
                                  /> Black
</div>
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