Skip to content

Commit ca110b0

Browse files
committed
Add mount attribute to judge mount status
1 parent dbc8491 commit ca110b0

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-tooltip",
3-
"version": "0.6.0",
3+
"version": "0.6.1",
44
"description": "react tooltip component",
55
"main": "dist/react-tooltip.js",
66
"scripts": {

src/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default class ReactTooltip extends Component {
2626
constructor (props) {
2727
super(props)
2828
this._bind('showTooltip', 'updateTooltip', 'hideTooltip')
29+
this.mount = true
2930
this.state = {
3031
show: false,
3132
multilineCount: 0,
@@ -51,16 +52,21 @@ export default class ReactTooltip extends Component {
5152
*
5253
**/
5354
globalHide () {
54-
this.hideTooltip()
55+
if(this.mount) {
56+
this.hideTooltip()
57+
}
5558
}
5659

5760
globalRebuild () {
58-
this.unbindListener()
59-
this.bindListener()
61+
if(this.mount) {
62+
this.unbindListener()
63+
this.bindListener()
64+
}
6065
}
6166

6267
componentWillUnmount () {
6368
this.unbindListener()
69+
this.mount = false
6470
let tag = document.querySelector('style[id="react-tooltip"]')
6571
document.getElementsByTagName('head')[0].removeChild(tag)
6672
window.removeEventListener('__react_tooltip_hide_event', this.globalHide)

0 commit comments

Comments
 (0)