Skip to content

Instantly share code, notes, and snippets.

@DrewDahlman
Created July 22, 2019 18:14
Show Gist options
  • Save DrewDahlman/a2cf3ab916761f4cf7d821e35f6a425f to your computer and use it in GitHub Desktop.
Save DrewDahlman/a2cf3ab916761f4cf7d821e35f6a425f to your computer and use it in GitHub Desktop.
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