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

118
Visualizações
Checking a variable in React and using to show an element

I have a redux piece of state that is selected. This will return an array of selections, e.g 3 words or what not.

With this, I want to continually check this variable and show and NOT element if the list is GREATER then 1, eg only show when filtered to 1 selection.

See below code:

const [activeRole, setActiveRole] = useState(false)
const searchResults = useSelector(state => state.jobsearch.roles.map(role => role.title))

  const handleActiveSelection = () => {
    if (searchResults.length > 1) {
      setActiveRole(true)
    }
  }

Would I need to use a useEffect to continually monitor this? How would I embed a clause into my element?

E.g: ONLY show when 1 selection?

          {finalSelection &&  (
            <MessageContainer>
              <Typography>
                You have selected {searchResults}
              </Typography>
            </MessageContainer>
          )}
about 4 years ago · Santiago Trujillo
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