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

316
Visualizações
React JS onClick() Sometimes doesn't work

I have been trying to fix this for hours. I found this issue originally on iOS for a website I had released. I have tested with the following code, and it will work 90% of the time, but randomly will not work.

<button className="p-8" onClick={() => (console.log("successful click"))}>test</button>

I use tailwindcss, but have tried adding the cursor: "pointer" style to the button and parent divs, which changed nothing, I have tried adding an id with a separate javascript addEventHandler, which changed nothing, I have tried adding onClick="void(0)" to both parent and child divs, which did nothing, I tried calling onTouchStart alongside onClick, which somewhat solved this issue but cause another issue where things were being double-clicked. I have tried EVERYTHING that I could find on the internet and nothing is working.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I figured it out. Upon inspecting the page, I saw that several of my buttons were flashing on the 'elements' panel. I had a separate function being called once per second that was updating the state of a number (I have a countdown timer on my page) that was completely unrelated to this button.

Updating the state of that item was causing every button to re-render every second, which takes milliseconds, but if you happened to click right when it rendered it would do nothing. Removing the logic of the timer setState() actually solved all of my problems with the clicking.

about 4 years ago · Juan Pablo Isaza Relatório
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