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

176
Views
How to check onClick on an element in react?

I need to check if I click on a react-select element. I thought doing it by id and check the mouse event if hits the component that I want. It seems that it doesn't accept id as param and it doesn't have one. So I can't check it with event listener.

Is there a way to solve this problem? Adding an id to the react-select or doing it in another way. Keep in mind that I need to know whether I click on the area of the select or outside.

Here is my code:

<Select
  defaultValue={defaultValue}
  options={options}
  styles={selectStyle()}
  onFocus={onFocus}
  onChange={onChange}
  placeholder={placeholder}
  value={value}
  id="123" // This way doesn't work
/>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try using onClick attribute.

const clickHandler = () => {
console.log("Select is clicked");
}

<Select
  defaultValue={defaultValue}
  options={options}
  styles={selectStyle()}
  onFocus={onFocus}
  onChange={onChange}
  onClick = {clickHandler}
  placeholder={placeholder}
  value={value}
  id="123" // This way doesn't work
/>
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!