pixijs / pixi-react

Write PIXI apps using React declarative style
https://pixijs.io/pixi-react/
MIT License
2.33k stars 177 forks source link

Incorrect type for useTick callback #309

Closed CreativeTechGuy closed 3 years ago

CreativeTechGuy commented 3 years ago

Description

The type for useTick as seen here indicates that the argument to the callback function delta could possibly be undefined. Referencing the pixi source type TickerCallback it shows that dt is always present.

I'd recommend using the type from pixijs to ensure that it's the same and doesn't diverge.

Steps to reproduce

Additional info

CreativeTechGuy commented 3 years ago

Also, I think there's some missing functionality also. In pixi the ticker listener is called with this === Ticker [ref] to allow the ticker handler function to access other properties of the ticker object (such as elapsedMS, FPS and more).

In the current implementation of useTick [ref] the callback cannot access this. I'd like to have access to that to match the functionality of Pixi.

inlet commented 3 years ago

Good point! We can add the ticker instance as the second argument as the hook will be often used with dash array function.

Feel free to create a PR, thanks!

inlet commented 3 years ago

Fixed in the new release https://github.com/inlet/react-pixi/releases/tag/v6.6.4

inlet commented 3 years ago

Thanks for contributing!

CreativeTechGuy commented 3 years ago

Oh dang you are fast. I didn't get a chance to reply. haha

I was going to ask why you wanted to pass a second argument instead of using .apply but I see you did both! Wonderful. 😄