just hide toottip overlay when there is no title

avoid rerender children when title is changed
This commit is contained in:
afc163 2015-10-26 16:30:27 +08:00
parent 11b47aa79b
commit 9b5311791e
2 changed files with 20 additions and 2 deletions

View File

@ -10,6 +10,14 @@ export default React.createClass({
mouseLeaveDelay: 0.1
};
},
getInitialState() {
return {
visible: false
};
},
onVisibleChange(visible) {
this.setState({ visible });
},
render() {
let transitionName = ({
top: 'zoom-down',
@ -17,12 +25,21 @@ export default React.createClass({
left: 'zoom-right',
right: 'zoom-left'
})[this.props.placement];
// Hide tooltip when there is no title
let visible = this.state.visible;
if (!this.props.title) {
visible = false;
}
return (
this.props.title ? <Tooltip transitionName={transitionName}
<Tooltip transitionName={transitionName}
overlay={this.props.title}
visible={visible}
onVisibleChange={this.onVisibleChange}
{...this.props}>
{this.props.children}
</Tooltip> : this.props.children
</Tooltip>
);
}
});

View File

@ -52,6 +52,7 @@
background-color: @tooltip-bg;
border-radius: @border-radius-base;
box-shadow: @overlay-shadow;
min-height: 34px;
}
// Arrows