Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Created September 7, 2019 16:30
Show Gist options
  • Save adamdriscoll/8e54ebb28448e31d70fe7a38109c143a to your computer and use it in GitHub Desktop.
Save adamdriscoll/8e54ebb28448e31d70fe7a38109c143a to your computer and use it in GitHub Desktop.
Render Component Function of Universal Dashboard
renderComponent: function(component, history, dynamicallyLoaded) {
if (component == null) return <React.Fragment/>;
if (Array.isArray(component)) {
return component.map(x => this.renderComponent(x, history));
}
var existingComponent = this.components.find(x => x.type === component.type);
if (existingComponent != null) {
return React.createElement(existingComponent.component, {
...component,
key: component.id,
history
});
} else if (component.isPlugin && !dynamicallyLoaded) {
return <LazyElement component={component} key={component.id} history={history}/>
}
return internalRenderComponent(component, history);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment