Skip to content

Commit 19a8a67

Browse files
committed
feat: Small bug fix to previous commit
Fix an issue in my first commit that caused a dereference of the incorrect "this" object.
1 parent 79342ce commit 19a8a67

File tree

3 files changed

+23
-25
lines changed

3 files changed

+23
-25
lines changed

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,11 @@ class ReactTooltip extends React.Component {
327327
self.updateTooltip(e)
328328

329329
if (getContent && Array.isArray(getContent)) {
330-
this.intervalUpdateContent = setInterval(() => {
330+
self.intervalUpdateContent = setInterval(() => {
331331
if (self.mount) {
332-
const {getContent} = this.props
332+
const {getContent} = self.props
333333
const placeholder = getTipContent(originTooltip, '', getContent[0](), isMultiline)
334-
const isEmptyTip = this.isEmptyTip(placeholder)
334+
const isEmptyTip = self.isEmptyTip(placeholder)
335335
self.setState({
336336
isEmptyTip
337337
})

standalone/react-tooltip.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,8 +1908,6 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
19081908
var self = this;
19091909

19101910
var updateState = function updateState() {
1911-
var _this5 = this;
1912-
19131911
self.setState({
19141912
originTooltip: originTooltip,
19151913
isMultiline: isMultiline,
@@ -1931,12 +1929,12 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
19311929
self.updateTooltip(e);
19321930

19331931
if (getContent && Array.isArray(getContent)) {
1934-
_this5.intervalUpdateContent = setInterval(function () {
1932+
self.intervalUpdateContent = setInterval(function () {
19351933
if (self.mount) {
1936-
var _getContent = _this5.props.getContent;
1934+
var _getContent = self.props.getContent;
19371935

19381936
var placeholder = (0, _getTipContent2.default)(originTooltip, '', _getContent[0](), isMultiline);
1939-
var isEmptyTip = _this5.isEmptyTip(placeholder);
1937+
var isEmptyTip = self.isEmptyTip(placeholder);
19401938
self.setState({
19411939
isEmptyTip: isEmptyTip
19421940
});
@@ -1962,7 +1960,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
19621960
}, {
19631961
key: 'updateTooltip',
19641962
value: function updateTooltip(e) {
1965-
var _this6 = this;
1963+
var _this5 = this;
19661964

19671965
var _state = this.state,
19681966
delayShow = _state.delayShow,
@@ -1981,13 +1979,13 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
19811979
if (this.isEmptyTip(placeholder) || disable) return; // if the tooltip is empty, disable the tooltip
19821980
var updateState = function updateState() {
19831981
if (Array.isArray(placeholder) && placeholder.length > 0 || placeholder) {
1984-
var isInvisible = !_this6.state.show;
1985-
_this6.setState({
1982+
var isInvisible = !_this5.state.show;
1983+
_this5.setState({
19861984
currentEvent: e,
19871985
currentTarget: eventTarget,
19881986
show: true
19891987
}, function () {
1990-
_this6.updatePosition();
1988+
_this5.updatePosition();
19911989
if (isInvisible && afterShow) afterShow();
19921990
});
19931991
}
@@ -2033,7 +2031,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
20332031
}, {
20342032
key: 'hideTooltip',
20352033
value: function hideTooltip(e, hasTarget) {
2036-
var _this7 = this;
2034+
var _this6 = this;
20372035

20382036
var _state2 = this.state,
20392037
delayHide = _state2.delayHide,
@@ -2053,18 +2051,18 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
20532051
}
20542052

20552053
var resetState = function resetState() {
2056-
var isVisible = _this7.state.show;
2054+
var isVisible = _this6.state.show;
20572055
// Check if the mouse is actually over the tooltip, if so don't hide the tooltip
2058-
if (_this7.mouseOnToolTip()) {
2059-
_this7.listenForTooltipExit();
2056+
if (_this6.mouseOnToolTip()) {
2057+
_this6.listenForTooltipExit();
20602058
return;
20612059
}
2062-
_this7.removeListenerForTooltipExit();
2060+
_this6.removeListenerForTooltipExit();
20632061

2064-
_this7.setState({
2062+
_this6.setState({
20652063
show: false
20662064
}, function () {
2067-
_this7.removeScrollListener();
2065+
_this6.removeScrollListener();
20682066
if (isVisible && afterHide) afterHide();
20692067
});
20702068
};
@@ -2099,7 +2097,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
20992097
}, {
21002098
key: 'updatePosition',
21012099
value: function updatePosition() {
2102-
var _this8 = this;
2100+
var _this7 = this;
21032101

21042102
var _state3 = this.state,
21052103
currentEvent = _state3.currentEvent,
@@ -2115,7 +2113,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
21152113
if (result.isNewState) {
21162114
// Switch to reverse placement
21172115
return this.setState(result.newState, function () {
2118-
_this8.updatePosition();
2116+
_this7.updatePosition();
21192117
});
21202118
}
21212119
// Set tooltip position
@@ -2155,7 +2153,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
21552153
}, {
21562154
key: 'render',
21572155
value: function render() {
2158-
var _this9 = this;
2156+
var _this8 = this;
21592157

21602158
var _state4 = this.state,
21612159
extraClass = _state4.extraClass,
@@ -2176,7 +2174,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
21762174
return _react2.default.createElement(Wrapper, _extends({ className: tooltipClass + ' ' + extraClass,
21772175
id: this.props.id,
21782176
ref: function ref(_ref) {
2179-
return _this9.tooltipRef = _ref;
2177+
return _this8.tooltipRef = _ref;
21802178
}
21812179
}, ariaProps, {
21822180
'data-id': 'tooltip',
@@ -2188,7 +2186,7 @@ var ReactTooltip = (0, _staticMethods2.default)(_class = (0, _windowListener2.de
21882186
id: this.props.id
21892187
}, ariaProps, {
21902188
ref: function ref(_ref2) {
2191-
return _this9.tooltipRef = _ref2;
2189+
return _this8.tooltipRef = _ref2;
21922190
},
21932191
'data-id': 'tooltip' }),
21942192
placeholder

0 commit comments

Comments
 (0)