# @react-vertex/gl-context

> React WebGL Context Component

Latest version **3.1.0** (published 2019-04-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @react-vertex/gl-context
pnpm add @react-vertex/gl-context
yarn add @react-vertex/gl-context
bun add @react-vertex/gl-context
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2019-04-28 |
| First published | 2019-03-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1234 |
| Author | Steven Hall |
| Maintainers | sghall |
| Keywords | react, hooks, webgl |

## Links

- npm: https://www.npmjs.com/package/@react-vertex/gl-context
- Repository: https://github.com/sghall/react-vertex
- Homepage: https://github.com/sghall/react-vertex/tree/master/packages/gl-context#readme
- Issues: https://github.com/sghall/react-vertex/issues
- npm.io page: https://npm.io/package/@react-vertex/gl-context

## Dependencies (2)

- [prop-types](https://npm.io/package/prop-types.md) ^15.7.2
- [@babel/runtime](https://npm.io/package/@babel/runtime.md) ^7.4.3

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.1.0 (latest) — 2019-04-28
- 3.0.0 — 2019-04-24
- 2.0.0 — 2019-04-20
- 1.2.0 — 2019-04-14
- 1.1.0 — 2019-04-12
- 1.0.0 — 2019-04-08
- 0.4.0 — 2019-04-05
- 0.3.0 — 2019-04-04
- 0.2.0 — 2019-04-04
- 0.1.11 — 2019-03-29

## README

# `@react-vertex/gl-context`

[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://github.com/sghall/react-vertex/blob/master/packages/gl-context/LICENSE)
[![bundlephobia](https://badgen.net/bundlephobia/minzip/@react-vertex/gl-context)](https://bundlephobia.com/result?p=@react-vertex/gl-context)
[![npm version](https://img.shields.io/npm/v/@react-vertex/gl-context.svg)](https://www.npmjs.com/package/@react-vertex/gl-context)

### [Documentation and Examples](https://react-vertex.com)

A React component to render a canvas and create a WebGL context.  It uses the render prop pattern.  For SSR this component will not render its children. **Note: it's not required to use this component to use the other hook packages.**

##### Install via npm:
```js
npm install @react-vertex/gl-context
```

#### Importing:

```js
import GlContext from '@react-vertex/gl-context'
```

##### Props:

`width`: Number for width of canvas element (defaults to 1).

`height`: Number for height of canvas element (defaults to 1).

`antialias (optional)`: Boolean to turn on antialiasing (defaults to false).

`canvasClass (optional)`: String class to be added to the canvas.

`canvasStyle (optional)`: An object of styles to be applied to the canvas.

`extensions (optional)`: An array of strings identifying the [WebGL extensions](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Using_Extensions) you want loaded in the context.

`contextAttrs (optional)`: An object of context attributes you want applied.

`children`: A function that accepts the context (`gl`) and an array of the extension return values (if using any extensions are being used) defaults to an empty array.

##### Example Usage:

```js
import React, { useRef } from 'react'
import GLContext from '@react-vertex/gl-context'
import { useMeasure } from '@react-vertex/dom-hooks'

function Example() {
  const container = useRef()
  const { width } = useMeasure(container)

  return (
    <div ref={container}>
      <GLContext
        width={width}
        height={width}
        canvasStyle={{
          borderRadius: 4
        }}
      >
        {(gl, extensions) => (
          <Scene gl={gl} extensions={extensions} />
        )}
      </GLContext>
    </div>
  )
}

export default Example
```

---
_Source: https://npm.io/package/@react-vertex/gl-context · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
