Skip to content

Commit

Permalink
refactor(node-renderer): do not mutate node styles
Browse files Browse the repository at this point in the history
  • Loading branch information
moklick committed Oct 25, 2021
1 parent c42ba1f commit e8d2600
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/container/NodeRenderer/index.tsx
Expand Up @@ -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]);
Expand All @@ -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}
Expand Down

0 comments on commit e8d2600

Please sign in to comment.