This commit is contained in:
ztplz 2019-02-24 15:49:12 +08:00 committed by zombieJ
parent cca47ac3be
commit 94814d955f

View File

@ -24,15 +24,18 @@ export default class ActionButton extends React.Component<ActionButtonProps, Act
loading: false, loading: false,
}; };
} }
componentDidMount() { componentDidMount() {
if (this.props.autoFocus) { if (this.props.autoFocus) {
const $this = ReactDOM.findDOMNode(this) as HTMLInputElement; const $this = ReactDOM.findDOMNode(this) as HTMLInputElement;
this.timeoutId = setTimeout(() => $this.focus()); this.timeoutId = setTimeout(() => $this.focus());
} }
} }
componentWillUnmount() { componentWillUnmount() {
clearTimeout(this.timeoutId); clearTimeout(this.timeoutId);
} }
onClick = () => { onClick = () => {
const { actionFn, closeModal } = this.props; const { actionFn, closeModal } = this.props;
if (actionFn) { if (actionFn) {