refactor(node-renderer): do not mutate node styles

This commit is contained in:
moklick
2021-10-25 16:56:54 +02:00
parent c42ba1fa1d
commit e8d26002a1
+3 -3
View File
@@ -83,14 +83,14 @@ function Node({
const childRect = useMemo(() => getRectOfNodes(childNodes), [childNodes]);
const isParentNode = !!childNodes.length;
node.style = useMemo(() => {
const style = useMemo(() => {
if (isParentNode) {
return {
...node.style,
width: Math.floor(childRect.width) + 20,
height: Math.floor(childRect.height) + 20,
boxSizing: 'border-box',
};
} as React.CSSProperties;
}
return node.style;
}, [childRect.width, childRect.height, isParentNode, node.style]);
@@ -111,7 +111,7 @@ function Node({
<NodeComponent
id={node.id}
className={node.className}
style={node.style}
style={style}
type={nodeType}
data={node.data}
sourcePosition={node.sourcePosition}