How do I clear the value of the time selection component RangePicker in antd-design?

 <Form.Item label={fieldLabels.createTime}>
                                            <RangePicker
                                                ref="myTextInput"
                                                showTime={{format: "HH:mm"}}
                                                format="YYYY-MM-DD HH:mm"
                                                placeholder={["", ""]} style={{width: 210}}
                                                onChange={this.handlePickerChange}/>
</Form.Item>
Mar.23,2021

state bind value, Click to set

state = {
    value: '',
};

// 
handleClick = () => {
    this.setState({ value: null });
}


// render:
<RangePicker value={this.state.value}/>

add the value attribute to the RangePicker to become a controlled component. When emptying, set the value to null


use getFieldDecorator to wrap the RangPicker.
then use setFieldsValue to set its value to undefined


state = {

keyValue: '',

};

give him a key = {this.state.keyValue}
Click to reset this.setState ({keyValue:new Date ()}) and you can empty it, which is equivalent to rendering a new one to achieve

.

how to do this


how is it emptied

Menu