반응형
import produce from 'immer';
ERROR in src/QuickStart/TodoListPage/TodoListPage.tsx:37:46
TS7006: Parameter 'draft' implicitly has an 'any' type.
35 | const toggleDone = (no:number)=> {
36 | let index = todoList.findIndex((todo) => todo.no === no);
> 37 | let newTodoList = produce(todoList, (draft) => {
| ^^^^^
38 | draft.splice(index, 1);
39 | });
40 | setTodoList(newTodoList);
수정
import { produce } from 'immer';
const addTodo = (todo: string) => {
let newTodoList = produce(todoList, (draft : any)=> {
draft.push({no: new Date().getTime(), todo: todo, done:false});
});
setTodoList(newTodoList);
};
반응형