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

177
Vistas
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 Respuestas
Responde la pregunta

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 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