getPixiApp
The getPixiApp hook provides a way to access the root PIXI.Application instance created by the PixiApplicationProvider or PixiCanvas component.
This is useful when you need to interact directly with the Pixi.js application, for example, to access the renderer.
This hook must be called from a component that is a descendant of the <PixiApplicationProvider /> or <PixiCanvas /> component.
If used outside of this context, it will throw an error.
import { getPixiApp, Container, PixiCanvas } from "pixi-solid";import { createEffect } from "solid-js";
const MyComponent = () => { const app = getPixiApp();
createEffect(() => { // You can now safely use the Pixi.js Application instance console.log("Pixi.js Application instance:", app); });
return <Container>{/* Your components here*/}</Container>;};
export const DemoApp = () => { return ( <PixiCanvas> <MyComponent /> </PixiCanvas> );};When to use it
Section titled “When to use it”- When you need direct access to the
PIXI.Applicationinstance to perform operations not covered by specificpixi-solidcomponents. - To get information about the Pixi.js renderer, such as its dimensions, resolution, or view.
Further reading
Section titled “Further reading”- Read more about the
PIXI.Applicationclass in the PixiJS documentation.