-
Notifications
You must be signed in to change notification settings - Fork 185
Open
Description
Getting the following error:
ERROR in src/Components/Task.tsx:29:18
TS2345: Argument of type '(TaskDo | { todo: string; length: number; toString(): string; toLocaleString(): string; pop(): TaskDo | undefined; push(...items: TaskDo[]): number; concat(...items: ConcatArray<...>[]): TaskDo[]; concat(...items: (TaskDo | ConcatArray<...>)[]): TaskDo[]; ... 28 more ...; [Symbol.unscopables](): { ...; }; })[]' is not assignable to parameter of type 'SetStateAction<TaskDo[]>'.
Type '(TaskDo | { todo: string; length: number; toString(): string; toLocaleString(): string; pop(): TaskDo | undefined; push(...items: TaskDo[]): number; concat(...items: ConcatArray<...>[]): TaskDo[]; concat(...items: (TaskDo | ConcatArray<...>)[]): TaskDo[]; ... 28 more ...; [Symbol.unscopables](): { ...; }; })[]' is not assignable to type 'TaskDo[]'.
Type 'TaskDo | { todo: string; length: number; toString(): string; toLocaleString(): string; pop(): TaskDo | undefined; push(...items: TaskDo[]): number; concat(...items: ConcatArray<...>[]): TaskDo[]; concat(...items: (TaskDo | ConcatArray<...>)[]): TaskDo[]; ... 28 more ...; [Symbol.unscopables](): { ...; }; }' is not assignable to type 'TaskDo'.
Type '{ todo: string; length: number; toString(): string; toLocaleString(): string; pop(): TaskDo | undefined; push(...items: TaskDo[]): number; concat(...items: ConcatArray<TaskDo>[]): TaskDo[]; concat(...items: (TaskDo | ConcatArray<...>)[]): TaskDo[]; ... 28 more ...; [Symbol.unscopables](): { ...; }; }' is missing the following properties from type 'TaskDo': id, isDone
27 | const handleEdit = (e:React.FormEvent,id:number)=>{
28 | e.preventDefault();
> 29 | setTasks(tasks.map((task) => task.id === id ? { ...tasks, todo: editTask } : task));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30 | setEdit(false);
31 | }
32 |
My Code:-
const handleEdit = (e:React.FormEvent,id:number)=>{
e.preventDefault();
**setTasks(tasks.map((task) => task.id === id ? { ...tasks, todo: editTask } : task));** //ERROR
setEdit(false);
}
@piyush-eon : Kindly advise on this 🙏🙏🙏
src.zip
Metadata
Metadata
Assignees
Labels
No labels