Skip to content

Commit

Permalink
fix destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Jun 30, 2015
1 parent 3e58a02 commit 94f9138
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions examples/handleVisibleChange.js
Expand Up @@ -15,7 +15,15 @@ var Test = React.createClass({
visible: visible
});
},
handleDestroy(){
this.setState({
destroy:true
});
},
render() {
if(this.state.destroy){
return null;
}
return <div >
<div style={{marginTop: 300, marginLeft: 100, marginBottom: 100}}>
<Tooltip
Expand All @@ -27,6 +35,7 @@ var Test = React.createClass({
<a href='#' onClick={preventDefault}>trigger</a>
</Tooltip>
</div>
<button onClick={this.handleDestroy}>destroy</button>
</div>;
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rc-tooltip",
"version": "2.2.0",
"version": "2.2.1",
"description": "tooltip ui component for react",
"keywords": [
"react",
Expand Down
8 changes: 8 additions & 0 deletions src/Tooltip.jsx
Expand Up @@ -106,6 +106,14 @@ class Tooltip extends React.Component {
}
}

componentWillUnmount() {
if (this.tipContainer) {
React.unmountComponentAtNode(this.tipContainer);
document.body.removeChild(this.tipContainer);
this.tipContainer = null;
}
}

render() {
if (this.state.visible) {
this.popupRendered = true;
Expand Down

0 comments on commit 94f9138

Please sign in to comment.