@playcanvas/react
Version:
A React renderer for PlayCanvas – build interactive 3D applications using React's declarative paradigm.
17 lines • 534 B
JavaScript
import { useContext, createContext } from "react";
export const ParentContext = createContext(undefined);
/**
* This hook is returns parent entity.
* @returns {Entity} parent - The parent entity.
*
* @example
* const parent = useParent();
*/
export const useParent = () => {
const context = useContext(ParentContext);
if (context === undefined) {
throw new Error('`useParent` must be used within an App or Entity via a ParentContext.Provider');
}
return context;
};
//# sourceMappingURL=use-parent.js.map