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) { close(e) {
let dom = React.findDOMNode(this); 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({ this.setState({
closing: true closing: true
}); });
@ -26,11 +29,6 @@ class AntTag extends React.Component {
this.props.onClose.call(this, e); this.props.onClose.call(this, e);
} }
componentDidMount() {
let dom = React.findDOMNode(this);
dom.style.width = (dom.getBoundingClientRect().width || dom.offsetWidth) + 'px';
}
render() { render() {
let close = this.props.closable ? let close = this.props.closable ?
<i className="anticon anticon-cross" onClick={this.close.bind(this)}></i> : ''; <i className="anticon anticon-cross" onClick={this.close.bind(this)}></i> : '';