React TypeScript Dołącz do tablicy

interface IState {
  newTask: string;
  tasks: Array<ITask>;
}

addTask(name:string) {
  const newTask: ITask = {name, done: false}
  this.setState((prevState) => ({
    tasks: [...(prevState.tasks ?? []), newTask]
  }));
}
Defiant Dove