Skip to content

Commit

Permalink
remove example. need to be nested in components.
Browse files Browse the repository at this point in the history
  • Loading branch information
brianzinn committed Dec 1, 2019
1 parent c208348 commit 8b8d037
Showing 1 changed file with 0 additions and 57 deletions.
57 changes: 0 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,63 +269,6 @@ 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-babylonjs'

// later inside a functional component:

export default () => {
const engine = useBabylonEngine()
const canvas = useBabylonCanvas()
const scene = useBabylonScene()
console.log({ engine, canvas, scene })

return (
<div>See console</div>
)
}

````

### HOC

```jsx
import { withBabylonJS, withScene } from 'react-babylonjs'
const DemoComponent = ({ scene, engine, canvas }} => {
console.log({ scene, engine, canvas })
return (
<div>See console</div>
)
}
export default withBabylonJS(withScene(DemoComponent))
```

### direct Consmuer

```jsx
import { WithSceneContext } from 'react-babylonjs'
const DemoComponent = ({ scene }} => {
const engine = scene.getEngine()
const canvas = engine.getCanvas()
console.log({ scene, engine, canvas })
return (
<div>See console</div>
)
}
export default () => (<WithSceneContext>{DemoComponent}</WithSceneContext>)
```

## Major Release History
> v1.0.0 (2018-11-29) - Add code generation, HoC, context provider
Expand Down

0 comments on commit 8b8d037

Please sign in to comment.