Skip to main content

onChange

Description​

Optional. Fires when a new date is selected in a date picker

Usage​

onChange?: (ev: { value: Date | null }) => void;

Parameters​

The callback of the event takes an object with the following parameter:

  • value - (required) Date object with the date as a newly selected value

Example​

function handleSelect({ value }: { value: Date | null }) {
console.log(value);
// date object or null
}

<DatePicker onChange={handleSelect} />

Details​

The handler function receives a date object with the date as a newly selected value of the date picker or null if the value is cleared.

Related article: Catching the change of the selected date

Related sample: DatePicker