Chú ý nếu sử dụng dạng :void ở arrow function & function (ok)

https://app.gitbook.com/@learnreac/s/project/deleteatask-itask-ok

Sử dụng handleSubmit ở dạng arrow function

private handleSubmit = async (e: React.FormEvent < HTMLFormElement > ): Promise<void> => {
    e.preventDefault();
    console.log('aaaaaaa');
}

Sử dụng handleSubmit ở dạng function

handleNewTask(e: React.FormEvent < HTMLFormElement > ): void {
  e.preventDefault();
  const newTask: ITask = {
    id: this.getCurrentTimestamp(),
    title: this.state.title,
    description: this.state.description,
    completed: false
  };
  this.setState({ title: '', description: '' });
  this.props.addANewTask(newTask);
}

Last updated

Was this helpful?