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

73
Vistas
React component does not call onClick handler

I have a component built with es6 class syntax. It's a simple component with just a diverse and some styling. Then, on the parent component (called app), I'd like to render that component and give it an onClick that calls the parent's onclick handler. So far, the parent renders the child like so:

<child_component onClick={this.clickhandler}>

And then I have a method in that parent component that I have bound to the parent's context in the constructor.

The component renders, but the click handler is never called when I click the component. Any idea why?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Since child componet isn't a native DOM element but, another React component, onClick as defined here is simply a property of that component. What you need to do is, inside of the child component pass the onClick prop to an DOM component's onClick event:

var ChildComponet= React.createClass({
 render: function() {
 return (
   <div className="childcomponent" onClick={this.props.onClick}>
   ...
    </div>
  );
 }
 });
over 4 years ago · Santiago Trujillo 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