refactor(node-renderer): do not mutate node styles
This commit is contained in:
@@ -83,14 +83,14 @@ function Node({
|
|||||||
const childRect = useMemo(() => getRectOfNodes(childNodes), [childNodes]);
|
const childRect = useMemo(() => getRectOfNodes(childNodes), [childNodes]);
|
||||||
const isParentNode = !!childNodes.length;
|
const isParentNode = !!childNodes.length;
|
||||||
|
|
||||||
node.style = useMemo(() => {
|
const style = useMemo(() => {
|
||||||
if (isParentNode) {
|
if (isParentNode) {
|
||||||
return {
|
return {
|
||||||
...node.style,
|
...node.style,
|
||||||
width: Math.floor(childRect.width) + 20,
|
width: Math.floor(childRect.width) + 20,
|
||||||
height: Math.floor(childRect.height) + 20,
|
height: Math.floor(childRect.height) + 20,
|
||||||
boxSizing: 'border-box',
|
boxSizing: 'border-box',
|
||||||
};
|
} as React.CSSProperties;
|
||||||
}
|
}
|
||||||
return node.style;
|
return node.style;
|
||||||
}, [childRect.width, childRect.height, isParentNode, node.style]);
|
}, [childRect.width, childRect.height, isParentNode, node.style]);
|
||||||
@@ -111,7 +111,7 @@ function Node({
|
|||||||
<NodeComponent
|
<NodeComponent
|
||||||
id={node.id}
|
id={node.id}
|
||||||
className={node.className}
|
className={node.className}
|
||||||
style={node.style}
|
style={style}
|
||||||
type={nodeType}
|
type={nodeType}
|
||||||
data={node.data}
|
data={node.data}
|
||||||
sourcePosition={node.sourcePosition}
|
sourcePosition={node.sourcePosition}
|
||||||
|
|||||||
Reference in New Issue
Block a user