Browse Source

spining backward support

pull/1606/head
RaoHai 9 years ago
parent
commit
1547dc5e31
  1. 2
      components/spin/demo/nested.md
  2. 15
      components/spin/index.jsx

2
components/spin/demo/nested.md

@ -27,7 +27,7 @@ const Card = React.createClass({
); );
return ( return (
<div> <div>
<Spin spinning={this.state.loading}>{container}</Spin> <Spin spining={this.state.loading}>{container}</Spin>
切换加载状态:<Switch checked={this.state.loading} onChange={this.toggle} /> 切换加载状态:<Switch checked={this.state.loading} onChange={this.toggle} />
</div> </div>
); );

15
components/spin/index.jsx

@ -12,8 +12,7 @@ export default class Spin extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
const { spining } = props; const spinning = this.getSpinning(props);
const spinning = props.spinning && spining;
this.state = { this.state = {
spinning, spinning,
}; };
@ -34,9 +33,17 @@ export default class Spin extends React.Component {
findDOMNode(this).className += ` ${this.props.prefixCls}-show-text`; findDOMNode(this).className += ` ${this.props.prefixCls}-show-text`;
} }
} }
getSpinning(props) {
warning(!('spining' in this.props), '`spining` property of Popover is a spell mistake, use `spinning` instead.');
const { spinning, spining } = props;
// Backwards support
if (spining !== undefined) {
return spining;
}
return spinning;
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
const { spining = true } = nextProps; const spinning = this.getSpinning(nextProps);
const spinning = nextProps.spinning && spining; // Backwards support
if (this.debounceTimeout) { if (this.debounceTimeout) {
clearTimeout(this.debounceTimeout); clearTimeout(this.debounceTimeout);
} }

Loading…
Cancel
Save