Created
July 22, 2019 18:14
-
-
Save DrewDahlman/a2cf3ab916761f4cf7d821e35f6a425f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WebGLElement extends React.PureComponent { | |
// Switch to check the type: | |
// this could be expanded to include other elements | |
getComponent(contextValues, props) { | |
switch (props.type) { | |
case "image": | |
return <ImageBlock {...contextValues} {...props} />; | |
break; | |
case "example-image": | |
return <ExampleImage {...contextValues} {...props} />; | |
break; | |
default: | |
return false; | |
break; | |
} | |
} | |
render() { | |
return ( | |
<EffectContext.Consumer> | |
{contextValues => this.getComponent({ ...contextValues }, this.props)} | |
</EffectContext.Consumer> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment