diff --git a/src/components/Render/index.js b/src/components/Render/index.js index 7664943..856d4d5 100644 --- a/src/components/Render/index.js +++ b/src/components/Render/index.js @@ -23,22 +23,21 @@ const renderDebug = ({ x, y, width, height, axisX1, axisX2, axisY }) => <> ; -const render = (data, extraProps) => { +const render = (data, key) => { if (typeof data === 'string') { return data; } const { type, props, debug, box } = data; - const children = (data.children || []).map( - (data, key) => render(data, { key })); + const children = (data.children || []).map(render); - return <> + return { React.createElement( nodeTypes[type] ? nodeTypes[type].default : type, - { ...extraProps, ...props }, + props, children.length === 1 ? children[0] : children) } { debug && renderDebug(box) } - ; + ; }; class Render extends React.PureComponent { @@ -74,7 +73,13 @@ class Render extends React.PureComponent { const { data } = this.props; return
- { render(data, { onReflow: this.provideSVGData }) } + { render({ + ...data, + props: { + ...data.props, + onReflow: this.provideSVGData + } + }) }
; } }