Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

79
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!