Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!