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

116
Views
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
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!