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

318
Vistas
Why is onClick={() => this.handleClick()} not recommended in React.js?

According to the React.js documentation, the expression:

onClick={() => this.handleClick()}

is not recommended:

In most cases, this is fine. However, if this callback is passed as a prop to lower components, those components might do an extra re-rendering.

But in what cases and why does it happen? Can anybody explain or give an example?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

if you use this call back only on a plain html tag i think it should be fine. but problem is where you pass this type of callbacks as a prop to a child component. if your top level component happen to rerender and you don't want to child component rerender, if use memo on child component, it rerender anyway because when top level component rerender that callback recreated and each time you check for prev and next prop of child component it is new every time.

================== TopComponent  (props) ============

+------- Child Component - (onClick={()=> console.log('rerendered every time')}) --+
|         memo check funciton ===>(prev,next) => prev===next                       |                               
+----------------------------------------------------------------------------------+


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