Skip to main content

onChange

Description

Fires when a new date is selected in a calendar

Usage

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

Parameters

  • value - (required) an object with the newly selected value of the calendar or null if the value is cleared

Example

function handleChange(ev: { value: Date | null }) {
const newValue = ev;
console.log(newValue);
// => { value: Thu Apr 20 2023 00:00:00 GMT+0300 }
}

<Calendar value={new Date(2022, 2, 18)} onChange={handleChange} />

Details

The handler function receives an object with the newly selected value of the calendar or null if the value is cleared.

Related article: Catching the change of the selected date