Closed josegamboa closed 1 year ago
useApp
is a hook which must be called inside an AppProvider
. You can either create this yourself, or use the default one provided through the Stage component. This means you need a Stage component around MyComponent.
@AndreasWintherMoen , thanks a lot for helping with it.
Yep, I was missing the App provider in App.tsx:
Probably this is an opportunity to improve documentation.
Current Behavior
Hi,
I am trying to use
useApp ()
hook, but it is throwing up an exception, not sure if I am using it right, just checked the documentation below:https://reactpixi.org/hooks#useapp
invariant.js:24 Uncaught Invariant Violation: No Context found with
PIXI.Application
. Make sure to wrap component withAppProvider
at invariant (http://localhost:3004/static/js/bundle.js:484:15) at useApp (http://localhost:3004/static/js/bundle.js:21143:3) at MyComponent (http://localhost:3004/static/js/bundle.js:115:66) at renderWithHooks (http://localhost:3004/static/js/bundle.js:44313:22) at mountIndeterminateComponent (http://localhost:3004/static/js/bundle.js:47599:17) at beginWork (http://localhost:3004/static/js/bundle.js:48895:20) at HTMLUnknownElement.callCallback (http://localhost:3004/static/js/bundle.js:33905:18) at Object.invokeGuardedCallbackDev (http://localhost:3004/static/js/bundle.js:33949:20) at invokeGuardedCallback (http://localhost:3004/static/js/bundle.js:34006:35) at beginWork$1 (http://localhost:3004/static/js/bundle.js:53880:11) `Expected Behavior
Use app constant to access the application
Steps to Reproduce
Execute next chunk of code: ` import { BlurFilter } from 'pixi.js'; import { Stage, Container, Sprite, Text, useApp } from '@pixi/react'; import { useMemo } from 'react';
const MyComponent = () => { const blurFilter = useMemo(() => new BlurFilter(4), []); const app = useApp ();
return (
); };
export default MyComponent;`
`
Environment
@pixi/react
version: 7.0.1pixi.js
version: 7.1.0React
version: 18.0.0ReactDOM
version: 18.0.0Possible Solution
No response
Additional Information
No response