Can't get the value insert of the DateTimePicker Component

Hello, 

I'm finding issues working with the DateTimePicker Component, I can't get the value inserted, here is my code : 


import React, {useEffect, useState} from 'react';
import { DateTimePickerComponent } from '@syncfusion/ej2-react-calendars';
import './formulaireDisponibilites.css';

const FormulaireDisponibilites = () => {

const [datetime, setDatetime] = useState([]);
const minDatetime = new Date();

const handleChange = (event) => {
console.log('value changed');
console.log(event.value);
setDatetime(event.value);
console.log(datetime)
}


return (
<div>
<form>
<DateTimePickerComponent
placeholder="Indiquez la date et l'heure"
id="datetimepicker"
min={minDatetime}
format="dd-MM-yy HH:mm"
change={handleChange()}
step={30}
/>;
</form>
</div>
);
}

export default FormulaireDisponibilites;

I get this error : 'Uncaught TypeError: Cannot read properties of undefined (reading 'value')' saying that the problem comes from the event.value 

Do you know how I can solve this ? 


Thank you


2 Replies 1 reply marked as answer

JF Julie Fino August 29, 2022 12:40 PM UTC

I resolved this problem by removing '()' for the line `change={handleChange()}` so it turns out like this : 


Marked as answer

DR Deepak Ramakrishnan Syncfusion Team August 30, 2022 07:52 AM UTC

Hi Julie,


Thanks for your update.


We are glad that the issue get resolved at your end . Kindly refer to the documentation and demo links for more details about the DateTimepicker component .


Docs :https://ej2.syncfusion.com/react/documentation/datetimepicker/getting-started/ 


API docs https://ej2.syncfusion.com/react/documentation/api/datetimepicker/ 

Demo Link https://ej2.syncfusion.com/react/demos/#/bootstrap5/datetimepicker/default/ 


Thanks,
Deepak R.


Loader.
Up arrow icon