Help understanding the intended usage patterns of pixi-react #611
Replies: 1 comment 3 replies
-
The goal of @pixi/react is to provide a maintainable and extensible library for working with pixi.js using React.
Components with high frequency updates may choose to use the
@pixi/react is not perscriptive and there are many patterns that are used when developing applications, much like react itself. Best practices are not even totally agreed upon in the discord channel with developers sharing the pros/cons of the approaches they use for solving specific problems. I follow some general guidelines in my thought process when working in @pixi/react:
All the general best practices of avoiding unneccesary react re-renders apply, like using a state manager, avoiding context, debouncing, and memoizing components. Performance is king in games and simulations and re-renders in react can be pure overhead, so if you find your application is slowing down and your profiler is spending too much time in react, taking a ref and updating the component imperativly might be the last thing you need to boost that frame rate again. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello! I'm quite experienced in react for web applications, and I've used JavaScript game engines before. But while looking at some community/youtube tutorials about using pixi-react it's not clear to me what the libraries intentions are for how to be used. And the docs don't provided complex enough examples.
I can easily get things working but I'm having trouble understanding the intentions.
Is the goal for pixi-react to create all the privatives and add them to the stage for you and then you just use the ticker as an onupdate game loop like you would a normal pixijs scene ignoring react's reactive pipeline? or is the goal for you to use reacts reactive pipeline for state/rerender behavior to have a data first approach to state->view mapping?
All the tutorials I've come across seem to be the former, where once the primitive exists you forget its in react and just manipulate the object directly and get a reference to it via a react ref.
What is the actual recommended pattern?
-Thanks
Beta Was this translation helpful? Give feedback.
All reactions