From 67698ec1b517637fd57c5c1a4e9937837ca93704 Mon Sep 17 00:00:00 2001 From: ruffle1986 Date: Fri, 11 Sep 2015 14:12:41 +0200 Subject: [PATCH] avoid getBoundingClientRect() to be called twice --- src/js/index.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/js/index.jsx b/src/js/index.jsx index e3020f99d..a63c262ac 100644 --- a/src/js/index.jsx +++ b/src/js/index.jsx @@ -185,8 +185,9 @@ class ReactTooltip extends React.Component { }) } else if(this.state.effect === "solid"){ - let targetTop = e.target.getBoundingClientRect().top; - let targetLeft = e.target.getBoundingClientRect().left; + const boundingClientRect = e.target.getBoundingClientRect() + let targetTop = boundingClientRect.top; + let targetLeft = boundingClientRect.left; let node = React.findDOMNode(this); let tipWidth = node.clientWidth; let tipHeight = node.clientHeight;