still use Magic offsetWidth set

This commit is contained in:
afc163 2015-08-20 13:56:08 +08:00
parent 75fca79313
commit 9b28e46d4c

View File

@ -14,6 +14,9 @@ class AntTag extends React.Component {
close(e) {
let dom = React.findDOMNode(this);
dom.style.width = dom.offsetWidth + 'px';
// It's Magic Code, don't know why
dom.style.width = dom.offsetWidth + 'px';
this.setState({
closing: true
});
@ -26,11 +29,6 @@ class AntTag extends React.Component {
this.props.onClose.call(this, e);
}
componentDidMount() {
let dom = React.findDOMNode(this);
dom.style.width = (dom.getBoundingClientRect().width || dom.offsetWidth) + 'px';
}
render() {
let close = this.props.closable ?
<i className="anticon anticon-cross" onClick={this.close.bind(this)}></i> : '';