UNPKG

@pixi/react

Version:

Write PixiJS applications using React declarative style.

1 lines 917 B
{"version":3,"file":"useApplication.mjs","sources":["../../src/hooks/useApplication.ts"],"sourcesContent":["import { Application } from 'pixi.js';\nimport { useContext } from 'react';\nimport { Context } from '../components/Context';\nimport { invariant } from '../helpers/invariant';\n\n/**\n * @description Retrieves the nearest Pixi.js Application from the Pixi React context.\n */\nexport function useApplication()\n{\n const appContext = useContext(Context);\n\n invariant(\n appContext.app instanceof Application,\n 'No Context found with `%s`. Make sure to wrap component with `%s`',\n 'Application',\n 'AppProvider'\n );\n\n return appContext;\n}\n"],"names":[],"mappings":";;;;;;AAQO,SAAS,cAChB,GAAA;AACI,EAAM,MAAA,UAAA,GAAa,WAAW,OAAO,CAAA;AAErC,EAAA,SAAA;AAAA,IACI,WAAW,GAAe,YAAA,WAAA;AAAA,IAC1B,mEAAA;AAAA,IACA,aAAA;AAAA,IACA;AAAA,GACJ;AAEA,EAAO,OAAA,UAAA;AACX;;;;"}