MCPcopy Create free account
hub / github.com/gre/gl-react / componentDidMount

Method componentDidMount

packages/gl-react-headless/src/index.tsx:45–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43 gl: WebGLRenderingContext | null = null;
44
45 componentDidMount() {
46 invariant(
47 this.canvas,
48 "GLView: canvas is not available in componentDidMount!"
49 );
50 const {
51 webglContextAttributes,
52 onContextCreate,
53 onContextFailure,
54 } = this.props;
55 const gl = getContext(this.canvas!, webglContextAttributes);
56 this.webglContextAttributes = webglContextAttributes || {};
57 if (gl) {
58 this.gl = gl;
59 onContextCreate(gl);
60 } else {
61 onContextFailure(new Error("no-webgl-context"));
62 }
63 }
64
65 componentDidUpdate(prevProps: any) {
66 const { width, height } = this.props;

Callers

nothing calls this directly

Calls 1

getContextFunction · 0.70

Tested by

no test coverage detected