From 18bd368525a721e11aa58ca4f33414bbc23add55 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sun, 25 Feb 2018 11:41:58 -0500 Subject: [PATCH] Removing `return` from reflow implementations I don't think it will be necessary to wait for components to complete re-rendering before moving on with the reflow process. Parent components only depend on the bounding box and that is determined immediately when reflow is called --- src/components/SVG/Box.js | 2 +- src/components/SVG/Image.js | 2 +- src/components/SVG/Loop.js | 2 +- src/components/SVG/Pin.js | 2 +- src/components/SVG/Text.js | 2 +- src/components/SVG/VerticalLayout.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/SVG/Box.js b/src/components/SVG/Box.js index 4b452c3..0b17433 100644 --- a/src/components/SVG/Box.js +++ b/src/components/SVG/Box.js @@ -25,7 +25,7 @@ class Box extends React.PureComponent { axisX2: useAnchors ? box.axisX2 + padding : box.width + 2 * padding }); - return this.setStateAsync({ + this.setStateAsync({ width: this.getBBox().width, height: box.height + 2 * padding, contentTransform: `translate(${ padding } ${ padding + labelBox.height })`, diff --git a/src/components/SVG/Image.js b/src/components/SVG/Image.js index a7c61fa..6a55161 100644 --- a/src/components/SVG/Image.js +++ b/src/components/SVG/Image.js @@ -35,7 +35,7 @@ class Image extends React.PureComponent { const { padding } = this.props; const box = this.children[0].getBBox(); - return this.setStateAsync({ + this.setStateAsync({ width: Math.round(box.width + 2 * padding), height: Math.round(box.height + 2 * padding) }); diff --git a/src/components/SVG/Loop.js b/src/components/SVG/Loop.js index 048809d..bcb2839 100644 --- a/src/components/SVG/Loop.js +++ b/src/components/SVG/Loop.js @@ -93,7 +93,7 @@ class Loop extends React.PureComponent { box.offsetX = this.contentOffset.x; box.offsetY = this.contentOffset.y; - return this.setStateAsync({ + this.setStateAsync({ labelTransform: `translate(${ this.getBBox().width - labelBox.width - 10 } ${ this.getBBox().height + 2 })`, loopPaths: [ skip && skipPath(box, greedy), diff --git a/src/components/SVG/Pin.js b/src/components/SVG/Pin.js index 69dcb3c..2b9791c 100644 --- a/src/components/SVG/Pin.js +++ b/src/components/SVG/Pin.js @@ -14,7 +14,7 @@ class Pin extends React.PureComponent { reflow() { const { radius } = this.props; - return this.setBBox({ + this.setBBox({ width: radius * 2, height: radius * 2 }); diff --git a/src/components/SVG/Text.js b/src/components/SVG/Text.js index bc4c09d..b381e72 100644 --- a/src/components/SVG/Text.js +++ b/src/components/SVG/Text.js @@ -15,7 +15,7 @@ class Text extends React.PureComponent { height: box.height }); - return this.setStateAsync({ + this.setStateAsync({ transform: `translate(${-box.x} ${-box.y})` }); } diff --git a/src/components/SVG/VerticalLayout.js b/src/components/SVG/VerticalLayout.js index 0c781f1..121b671 100644 --- a/src/components/SVG/VerticalLayout.js +++ b/src/components/SVG/VerticalLayout.js @@ -96,7 +96,7 @@ class VerticalLayout extends React.PureComponent { offset += spacing + box.height; }); - return this.setStateAsync({ + this.setStateAsync({ childTransforms: this.updateChildTransforms(childBoxes), connectorPaths: withConnectors ? [ ...childBoxes.map(box => this.makeCurve(box)),