Skip to Content
🎉 @playcanvas/react 0.3.0! Now with React 19 support. Read more →
DocsAPIHooksHooks

Hooks

The are a a couple of hooks that are useful when working with @playcanvas/react. These can often be useful when creating custom components, hooks or utilities.

useApp

The useApp hook returns the Application instance that is currently active. This is useful if you need reference to the PlayCanvas Application instance directly.

import { useApp } from '@playcanvas/react/hooks'

useParent

The useParent hook returns the parent Entity of the current component. This can be useful if you need to access the parent entity of a component. For example, if you are creating a custom component that should be attached to a specific entity.

import { useParent } from '@playcanvas/react/hooks' const ChildEntity = () => { const parent = useParent(); console.log(parent); return <Entity> <Render type="box" /> </Entity> }; const ParentEntity = () => { return <ChildEntity />; };
Last updated on