@@ -8,6 +8,7 @@ import genId from "./genId";
88
99import type { Surface } from "./createSurface" ;
1010import type { NDArray } from "ndarray" ;
11+ import GLContext from "./GLContext" ;
1112
1213type Props = { |
1314 children ?: React$Element < * > | ( ( redraw ?: ( ) => void ) => React$Element < * > ) ,
@@ -45,6 +46,8 @@ type Props = {|
4546 */
4647export default class Bus extends Component < Props , * > {
4748 id : number = genId ( ) ;
49+ static contextType = GLContext ;
50+
4851 context : {
4952 glParent : Surface | Node ,
5053 glSurface : Surface ,
@@ -55,15 +58,6 @@ export default class Bus extends Component<Props, *> {
5558 index : 0 ,
5659 } ;
5760
58- static contextTypes = {
59- glParent : PropTypes . object . isRequired ,
60- glSurface : PropTypes . object . isRequired ,
61- } ;
62-
63- static childContextTypes = {
64- glParent : PropTypes . object . isRequired ,
65- } ;
66-
6761 componentDidMount ( ) {
6862 const { uniform, index } = this . props ;
6963 if ( uniform ) {
@@ -103,12 +97,6 @@ export default class Bus extends Component<Props, *> {
10397 this . redraw ( ) ;
10498 }
10599
106- getChildContext ( ) : { glParent : Bus } {
107- return {
108- glParent : this ,
109- } ;
110- }
111-
112100 glNode : ?Node = null ;
113101 _addGLNodeChild ( node : Node ) {
114102 this . glNode = node ;
@@ -204,9 +192,17 @@ export default class Bus extends Component<Props, *> {
204192 glSurface : { RenderLessElement , mapRenderableContent } ,
205193 } = this . context ;
206194 return (
207- < RenderLessElement ref = { mapRenderableContent ? this . onRef : undefined } >
208- { typeof children === "function" ? children ( this . redraw ) : children }
209- </ RenderLessElement >
195+ < GLContext . Provider
196+ value = { {
197+ glParent : this ,
198+ glSurface : this . context . glSurface ,
199+ glSizable : this . context . glSizable ,
200+ } }
201+ >
202+ < RenderLessElement ref = { mapRenderableContent ? this . onRef : undefined } >
203+ { typeof children === "function" ? children ( this . redraw ) : children }
204+ </ RenderLessElement >
205+ </ GLContext . Provider >
210206 ) ;
211207 }
212208}
0 commit comments