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

114
Visualizações
Console.Logging an OnClick Event not working with Mapped State

I've mapped some redux state across my app and am looking to when I select the text, it will create a console.log of the text. My eventual goal is to use this with useSelector and dispatch updates to the Redux store, but that's another question for another day.

I have created the following jsx:

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

    const SearchResultsText = ({ text }) => {
        return (
            <JobContainer>
                <JobSearchTypography>
                    {text}
                </JobSearchTypography>
          </JobContainer>
        );
      };

And have it within my app as such, which works!

           <JobContainer >
                {searchResults && searchResults.length < 3 && searchResults.map((result) =>
                    (<SearchResultsText text={result}/>)
                )}
                </JobContainer>

Now I have also created the following function e.g

   function handeClickRoleSelection() {
        console.log('you have clicked on')
    }

When I select on one of the following, i'd like to return in console.log, 'you have clicked on', title - but am unsure how to do this. I have tried applying the handleClickRoleSelection on each element of the jsx but nothing.

I have tried it with a basic p tag and it is functional. Where am I slipping up?

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