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

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