diff options
Diffstat (limited to 'src/components/ui/button')
-rw-r--r-- | src/components/ui/button/index.tsx | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/src/components/ui/button/index.tsx b/src/components/ui/button/index.tsx index 26fd6bcfe..a8bbfe730 100644 --- a/src/components/ui/button/index.tsx +++ b/src/components/ui/button/index.tsx | |||
@@ -169,20 +169,18 @@ class ButtonComponent extends Component<IProps> { | |||
169 | busy: false, | 169 | busy: false, |
170 | }; | 170 | }; |
171 | 171 | ||
172 | componentWillMount() { | 172 | constructor(props: IProps) { |
173 | this.setState({ busy: this.props.busy }); | 173 | super(props); |
174 | |||
175 | this.state = { | ||
176 | busy: props.busy || false, | ||
177 | }; | ||
174 | } | 178 | } |
175 | 179 | ||
176 | componentWillReceiveProps(nextProps: IProps) { | 180 | static getDerivedStateFromProps(nextProps: IProps) { |
177 | if (nextProps.busy !== this.props.busy) { | 181 | return { |
178 | if (this.props.busy) { | 182 | busy: nextProps.busy, |
179 | setTimeout(() => { | 183 | }; |
180 | this.setState({ busy: nextProps.busy }); | ||
181 | }, 300); | ||
182 | } else { | ||
183 | this.setState({ busy: nextProps.busy }); | ||
184 | } | ||
185 | } | ||
186 | } | 184 | } |
187 | 185 | ||
188 | render() { | 186 | render() { |