diff --git a/src/index.js b/src/index.js index bc985c49..b3206171 100755 --- a/src/index.js +++ b/src/index.js @@ -581,10 +581,11 @@ class ReactTooltip extends React.Component { show: true }, () => { - this.updatePosition(); - if (isInvisible && afterShow) { - afterShow(e); - } + this.updatePosition(() => { + if (isInvisible && afterShow) { + afterShow(e); + } + }); } ); } @@ -692,7 +693,7 @@ class ReactTooltip extends React.Component { } // Calculation the position - updatePosition() { + updatePosition(callbackAfter) { const { currentEvent, currentTarget, @@ -727,10 +728,12 @@ class ReactTooltip extends React.Component { if (result.isNewState) { // Switch to reverse placement return this.setState(result.newState, () => { - this.updatePosition(); + this.updatePosition(callbackAfter); }); } + callbackAfter(); + // Set tooltip position node.style.left = result.position.left + 'px'; node.style.top = result.position.top + 'px';