Closed hevans90 closed 2 years ago
I have tried manually calling app.destroy(true, true)
in a useEffect
's return function, but this threw errors as I assume <Stage>
has code to tear down the app after the component is unloaded.
I have also tried various manual .destroy
calls in onUnmount
from my <Stage>
, to no avail.
Hi @hevans90,
Yes if you use the <Stage>
component you cannot call destroy
manually as the instance will be controlled by React's lifecycle events (mount, update, unmount) and destroyed automatically on unmount.
This webgl context issue arise if you create multiple <Stage>
components, meaning you'll have basically 2 different renderers/webgl contexts.
I have no idea how to fix this really
Wait, does this mean that <Stage>
can't be used at all when using react-router-dom
and moving between pages?
It's not really related to react-pixi, but to pixi itself.. if you create multiple Application
s with webgl renderers, you'll starting to receive these warnings. The <Stage>
component creates an Application
at mount and destroys it at unmount
Can you isolate the issue and create an example on codesandbox?
https://github.com/pixijs/pixijs/issues/2233#issuecomment-449105397 this is the only solution I can find, which unfortunately basically invalidates your idea of destroying the app on unmount :(
So it turns out that I was using this library: https://www.npmjs.com/package/pixi-stats which was causing the issue. Turns out my FPS counter used a canvas itself that was messing with PIXI's CONTEXTIDs.
Sorry for the false report. Closing this, as routing works fine :)
Thanks for letting me know! 😉
Description
I am using a basic
<Stage>
component, and then usinguseApp
to manually write a lot of procedural galaxy/star generation stuff. It's great and works fine until you route away from the component and then route back to it.Steps to reproduce
react-router-dom
and route between a component containing<Stage>
and another component, more than once.Additional info
@inlet/react-pixi
version: 6.6.5React
version: 17.0.2ReactDOM
version: 17.0.2PIXI
version: 6.1.3