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

81
Vistas
Console.log in a custom .map function React

I've grabbed some data from redux and am mapping to a component.

If I console.log the text attribute, I do recieve all the data available. See below: https://gyazo.com/ae7167952d14623be30f80b69cc20d5c

However I would like to link this to an onClick event. E.g if I click on 'Data Analyst', this will console.log -> Data Analyst. This however is not functioning and I am getting zero response from these events.

What is incorrect on my syntax?

    const searchResults = useSelector(state => state.jobsearch.roles.map(role => role.title))

    const SearchResultsText = ({ text }) => {
        console.log(text)
        
        return (
            <JobContainer onClick={() => console.log(text)}>
                <JobSearchTypography 
                >
                    {text}
                </JobSearchTypography>
          </JobContainer>
        );
      };

When it's in the app itself, it looks as such:

                <JobContainer >
                {searchResults && searchResults.length < 3 && searchResults.map((result) =>
                    (<IndividualContainer >
                        <SearchResultsText text={result}/>
                    </IndividualContainer>
                    )
                )}
                </JobContainer>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If your text is inside JobSearchTypography then you can try it something like this-

<JobSearchTypography  onClick={(e)=>console.log(e.target.innerHTML)}>
      {text}
</JobSearchTypography>

about 4 years ago · Juan Pablo Isaza Denunciar
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