好久没写博客了,以前一直写vue,18年最后一个季度又开始经常写react,这次写一个基于antd form组件的自定义Input组件,写一个最简单的,让刚接触antd的小伙伴们能快速的了解基于form组件的自定义Input组件该如何入手。
import React, { PureComponent } from 'react';
import { Input, Icon } from 'antd';
class InputClear extends PureComponent {
constructor(props) {
super(props);
this.state = {
isShow: false,
v: '',
timer: null
};
}
componentDidMount() {
this.setState({
v: this.props.value || ''
});
}
UNSAFE_componentWillReceiveProps(nextProps) {
if ('value' in nextProps) {
this.setState({
v: nextProps.value
});
}
}
componentWillUnmount() {
clearTimeout(this.state.timer);
this.setState({
timer: null
});
}
handleFocus = (e)