pixijs / pixi-react

Write PIXI apps using React declarative style

Home Page:https://pixijs.io/pixi-react/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bug: click handlers not working on sprites

fergusmeiklejohn opened this issue · comments

Current Behavior

I've found a bug with the Sprite click handlers. See repo and 20sec video for clear explanation.. Basically if a Sprite Texture is in the stage, and the page is refreshed, the click handlers on the image Sprite will work, comment out the Texture and refresh and the click handlers stop working.

Expected Behavior

Click handlers should always work

Steps to Reproduce

https://stackblitz.com/edit/vitejs-vite-21bwq5?file=src%2FApp.tsx

CleanShot.2023-02-18.at.10.52.03.mp4

Environment

    "@pixi/react": "^7.0.2",
    "pixi.js": "^7.1.2",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"

Possible Solution

No response

Additional Information

No response

Seems related to this issue: #402

Hi! Are there any updates?)

commented

Click events are also not working for me. I guess pixi-react is just like... aspirational? Like it's not really a thing that is ready for general usage?

Hey I think you need to import pixi events to get it to work.
Add this as a import, it's enough to add it in the same file as where you define the Stage it will propagate.

import '@pixi/events';

This is mentioned in the FAQ of the pixi-react 'About' page: https://pixijs.io/pixi-react/

I tried adding the import in your stackblitz example and that did indeed resolve this problem.