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

80
Visualizações
pointerTap listener fires 7 times on PIXI.Sprite clicked once inside a React component

In a React application I use PIXI library for rendering animation, stage is created by @inlet/react-pixi, gsap for tweening.

On the first run the app creates a clickable sprite, then adds an eventlistener "pointerTap" with a callback.

useEffect(() => {
chestSprite.on('pointertap', callback);
})

Once chestSprite is clicked, callback fires 7 times instead of 1. How to make it fires only once?

I think the reason is that React re-renders several times on init and adds another eventListener on each render.

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

0

Try passing an empty array to the useEffect function:

useEffect(() => {
  chestSprite.on('pointertap', callback);
}, []);

Related documentation: https://reactjs.org/docs/hooks-effect.html#tip-optimizing-performance-by-skipping-effects

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