A'm stuck at 1:12:52 at Submit function onAdd. There is an error in React as:
Uncaught Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
const onSubmit = (e) => {
e.preventDefault()
if(!text) {
alert('Please add a task')
return
}
onAdd({ text, day, reminder } ) // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! This function throws an Error !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
setText('')
setDay('')
setReminder(false)
}
return (
<form className='add-form' onSubmit={onSubmit}>
<div className='form-control'>
<label>Task</label>
<input type='text' placeholder='Add Task'
value={text} onChange={(e) => setText(e.target.value)}
/>
</div>
<div className='form-control'>
<label>Day & Time</label>
<input type='text' placeholder='Add Date'
value={day} onChange={(e) => setDay(e.target.value)}
/>
</div>
<div className='form-control form-control-check'>
<label>Set Reminder</label>
<input type='checkbox' checked={reminder}
value={reminder} onChange={(e) =>
setReminder(e.currentTarget.checked)}
/>
</div>
<input type='submit' value='Save Task'
className='btn btn-block' />
</form>
)