Browse Source

💄 chore button code style

pull/13942/head
afc163 6 years ago
parent
commit
f65f3af928
No known key found for this signature in database GPG Key ID: 5F00908D72002306
  1. 10
      components/button/button.tsx

10
components/button/button.tsx

@ -105,9 +105,11 @@ class Button extends React.Component<ButtonProps, ButtonState> {
static getDerivedStateFromProps(nextProps: ButtonProps, prevState: ButtonState) {
if (nextProps.loading instanceof Boolean) {
return { loading: nextProps.loading }
return {
...prevState,
loading: nextProps.loading,
};
}
return null;
}
@ -126,7 +128,7 @@ class Button extends React.Component<ButtonProps, ButtonState> {
this.fixTwoCNChar();
}
componentDidUpdate(prevProps: ButtonProps, prevState: ButtonState) {
componentDidUpdate(prevProps: ButtonProps) {
this.fixTwoCNChar();
if (prevProps.loading && typeof prevProps.loading !== 'boolean') {
@ -135,7 +137,7 @@ class Button extends React.Component<ButtonProps, ButtonState> {
const { loading } = this.props;
if (loading && typeof loading !== 'boolean' && loading.delay) {
this.delayTimeout = window.setTimeout(() => this.setState({loading}), loading.delay);
this.delayTimeout = window.setTimeout(() => this.setState({ loading }), loading.delay);
} else if (prevProps.loading === this.props.loading) {
return;
} else {

Loading…
Cancel
Save