fix(nodetypes): use default when type not found

This commit is contained in:
moklick
2019-07-16 13:42:18 +02:00
parent 53581a846b
commit a431148890
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -1,11 +1,16 @@
import React, { PureComponent } from 'react';
import { Consumer } from '../GraphContext';
class NodeRenderer extends PureComponent {
renderNode(d, onNodeClick) {
const nodeType = d.data.type || 'default';
const NodeComponent = this.props.nodeTypes[nodeType];
if (!this.props.nodeTypes[nodeType]) {
console.warn(`No node type found for type "${nodeType}". Using fallback type "default".`);
}
const NodeComponent = this.props.nodeTypes[nodeType] || this.props.nodeTypes.default;
return (
<NodeComponent