Browse Source

adjust datepick reset logic

pull/12951/head
zombiej 6 years ago
parent
commit
69a2a92864
  1. 7
      components/date-picker/createPicker.tsx

7
components/date-picker/createPicker.tsx

@ -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…
Cancel
Save