mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-03 04:30:06 +08:00
adjust datepick reset logic
This commit is contained in:
parent
81a7d11ba3
commit
69a2a92864
@ -30,17 +30,20 @@ export default function createPicker(TheCalendar: React.ComponentClass): any {
|
||||
showToday: true,
|
||||
};
|
||||
|
||||
static getDerivedStateFromProps(nextProps: PickerProps, prevState: any) {
|
||||
static getDerivedStateFromProps(nextProps: PickerProps, prevState: PickerState) {
|
||||
const state: Partial<PickerState> = {};
|
||||
let open: boolean = prevState.open;
|
||||
|
||||
if ('open' in nextProps) {
|
||||
state.open = nextProps.open;
|
||||
open = nextProps.open || false;
|
||||
}
|
||||
if ('value' in nextProps) {
|
||||
state.value = nextProps.value;
|
||||
|
||||
if (
|
||||
nextProps.value !== prevState.value ||
|
||||
(!nextProps.open && nextProps.value !== prevState.showDate)
|
||||
(!open && nextProps.value !== prevState.showDate)
|
||||
) {
|
||||
state.showDate = nextProps.value;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user