Skip to content

Commit

Permalink
* datetime-picker: support for reseting state.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Jul 17, 2024
1 parent bfa6ad5 commit fc2d2ac
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/datetime-picker/src/component/date-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ export class DatePicker<T extends DatePickerOptions = DatePickerOptions> extends
limitPopInScreen: false,
} as Partial<PickOptions>;

protected _date: Date | null = null;
protected _date: Date | null | undefined;

constructor(props: T) {
super(props);
const {value} = this.state as PickState;
(this.state as PickState).value = this._calcValue(value);
getDefaultState(props?: RenderableProps<T> | undefined): PickState {
const state = super.getDefaultState(props);
return {
...state,
value: this._calcValue(state.value),
};
}

getDate() {
Expand Down

0 comments on commit fc2d2ac

Please sign in to comment.