diff --git a/README.md b/README.md index 6d2987c9..7cdd3f87 100644 --- a/README.md +++ b/README.md @@ -269,16 +269,61 @@ const App: React.FC = () => { } ``` +## Using context + +If you need to do something fancy with `scene`, `canvas`, or `engine`, there are a few ways: + +### react hooks + ```jsx // use Hooks to get engine/canvas/scene -import { useBabylonEngine, useBabylonCanvas, useBabylonScene } from 'react-react-babylonjs' +import { useBabylonEngine, useBabylonCanvas, useBabylonScene } from 'react-babylonjs' // later inside a functional component: -const engine = useBabylonEngine() -const canvas = useBabylonCanvas() -const scene = useBabylonScene() + +export default () => { + const engine = useBabylonEngine() + const canvas = useBabylonCanvas() + const scene = useBabylonScene() + console.log({ engine, canvas, scene }) + + return ( +