I have refactored a form with React hooks and useState, but I can't fire the function handleChange which is provided to onChange of input tags. Here is the code: The useState method
const [data, setData] = useState({
newDate: '',
startTime: '',
endTime: '',
});
const { newDate, startTime, endTime } = data;
The handleInputChange method
const handleInputChange = (e) => {
console.log('Inside handleChange');
setData({ ...data, [e.target.name]: e.target.value });
};
The inputs in the form
<input type="text" name="newDate" value={newDate} className="datepicker"
placeholder="Meeting Date" onChange={handleInputChange} />
<input style={{ width: '40%', marginRight: '10%' }} type="text" required
name="startTime" value={startTime} placeholder="00:00" onChange={handleInputChange}
className="timepicker" placeholder="Start Time" />
The onSubmit method and everything apart from this is working, but the input onChange method isn't firing. What exactly am i doing wrong here and how do I fix it?