From a06915845f467bed3167183ead459f9e05d3fe59 Mon Sep 17 00:00:00 2001 From: Jason Gaare Date: Thu, 10 Oct 2019 11:31:58 -0500 Subject: [PATCH 1/2] prevent update geometry getting called in a loop on some devices --- src/tooltip.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/tooltip.js b/src/tooltip.js index e9f48d5..c54a1e8 100644 --- a/src/tooltip.js +++ b/src/tooltip.js @@ -217,15 +217,17 @@ class Tooltip extends Component { }; measureContent = (e) => { - const { width, height } = e.nativeEvent.layout; - const contentSize = new Size(width, height); + if (!this.state.measurementsFinished) { + const { width, height } = e.nativeEvent.layout; + const contentSize = new Size(width, height); - this.setState({ contentSize }, () => { - this._updateGeometry(); - }); + this.setState({ contentSize }, () => { + this._updateGeometry(); + }); - if (React.Children.count(this.props.children) === 0) { - this.doChildlessPlacement(); + // if (React.Children.count(this.props.children) === 0) { + // this.doChildlessPlacement(); + // } } }; @@ -237,7 +239,9 @@ class Tooltip extends Component { }, () => { this.isMeasuringChild = false; - this._updateGeometry(); + if (this.state.contentSize.width) { + this._updateGeometry(); + } } ); }; From 68def60db9f0ff2c9dd036113857cc38e81b8e67 Mon Sep 17 00:00:00 2001 From: Jason Gaare Date: Thu, 10 Oct 2019 16:01:42 -0500 Subject: [PATCH 2/2] clean up / version bump --- package.json | 2 +- src/tooltip.js | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 57fa037..307a713 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native-walkthrough-tooltip", - "version": "1.1.2", + "version": "1.1.3", "description": "An inline wrapper for calling out React Native components via tooltip", "main": "src/tooltip.js", "scripts": { diff --git a/src/tooltip.js b/src/tooltip.js index c54a1e8..c9145ed 100644 --- a/src/tooltip.js +++ b/src/tooltip.js @@ -217,18 +217,12 @@ class Tooltip extends Component { }; measureContent = (e) => { - if (!this.state.measurementsFinished) { - const { width, height } = e.nativeEvent.layout; - const contentSize = new Size(width, height); + const { width, height } = e.nativeEvent.layout; + const contentSize = new Size(width, height); - this.setState({ contentSize }, () => { - this._updateGeometry(); - }); - - // if (React.Children.count(this.props.children) === 0) { - // this.doChildlessPlacement(); - // } - } + this.setState({ contentSize }, () => { + this._updateGeometry(); + }); }; onChildMeasurementComplete = (rect) => {