0

As in the title, I have in the app CalendarComponent from PrimeReact library, I want to type event from handleChange function. I don't want to leave it as :any as it's now. Can You suggest what should be typed here ?

const handleChange = (e: any) => {
    const newValues = e.value;
    if (!newValues) return;

    setValues(newValues);
    onChange({
      startDate: newValues[0],
      endDate: newValues[1],
    });
  };

  return (
    <CalendarComponent
      dateFormat="mm/yy"
      selectionMode={selectionMode}
      value={values}
      onChange={handleChange}
      showIcon
      {...rest}
    />
  );

thanks

marcinb1986
  • 708
  • 1
  • 11
  • 30

1 Answers1

2

You can import "CalendarChangeParams" as below

import { Calendar, CalendarChangeParams } from 'primereact/calendar';

And then use

const handleChange = (e: CalendarChangeParams) => {
// your code...
}
Hemant Sankhla
  • 923
  • 12
  • 23