Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

197
Visualizações
element (sporadically) fails to receive click event in React?

I'm having a strange issue where a click event on a button doesn’t get triggered in React. The function passed to the button onClick handler (sporadically) wouldn't run on click, so I added this event listener to the body so I could log the event object:

document.body.addEventListener('click', (e: any) => {
  console.log('test, e: ', e)
})

I could see that, when the button's onClick callback is run, the event object's path property looks like this:

enter image description here

The element button.Buttonstyles__ButtonWrapper... is the event target, the element that triggers the click event, which bubbles up until it reaches the Window.

But when it fails to run, the event object's path property looks like this:

enter image description here

It's as if the button didn't "receive" the click event. It should have been the event target. Instead, some parent element was the target - in this case, div.sc-bdvvaa.bmpHsj, but sometimes it was some other parent element higher up.

This happens (seemingly) sporadically (most times it works).

Any ideas?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda