Todolist(3) - 삭제

이진아·2021년 7월 1일
0

toy Project

목록 보기
3/4

주제 : TodoList

기능 :
1. 원하는 item onClick하면 title, content 내용이 나옴
2. 수정 기능
3. 삭제 기능
4. 추가 기능

<3. 삭제 기능 >

삭제 기능은 버튼을 클릭을 하게 되면 해당 item이 제거 되는 형식이다.

const removelist = (id) => {
        setTodos(todos.filter(todo => {
          return todo.id !== id;
        }));
      };

삭제할 때 사용되는 removelist 함수를 만들어 주었고
handeclike 함수랑 비슷한 방식이다.

<button style={{margin:'50px 0 0 0'}} onClick={() => removelist(id)}>
                    삭제
                </button>

위에서 만든 rmovelist함수를 버튼이 click 할 때 발생하도록 만든다.

git :
https://github.com/jinah26/bearTodolist

profile
새싹 개발자><

0개의 댓글