-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
중복 제거 및 완료 버튼 수정 #2
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수고하셨습니다!! 로컬스토리지 저장까지 구현해서 올리면 다시 리뷰 남기겠습니다!
if (e.type === "keypress" && e.key !== "Enter") { | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
수정할 때 엔터를 누르면 저장이 되는데 완료를 누르면 저장이 안되더라구요.. 그래서 keypress도 추가 했습니다!
const [newText, setNewTest] = useState(todoItem.text); | ||
const [edited, setEdited] = useState(false); | ||
const [newText, setNewText] = useState(todoItem.text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오타 있어서 수정했습니다
const updateTodoList = (update) => { | ||
setTodoList( | ||
todoList.map((item) => | ||
item.id === todoItem.id ? { ...item, ...update(item) } : item | ||
) | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onChangeCheckbox, onClickSubmitButton, onClickDeleteButton 함수에서 map 함수를 사용하여 새로운 todoList를 생성하는 부분이 반복되고 있습니다. 이 부분을 별도의 함수로 분리했습니다.
const onChangeCheckbox = () => { | ||
const nextTodoList = todoList.map((item) => ({ | ||
...item, | ||
// id 값이 같은 항목의 checked 값을 Toggle 함 | ||
checked: item.id === todoItem.id ? !item.checked : item.checked, | ||
})); | ||
|
||
setTodoList(nextTodoList); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updateTodoList 함수를 사용하면 이 반복 코드를 줄일 수 있습니다.
리뷰 남깁니다.
TodoList 기능 잘 구현이 됐습니다. 저도 잘 모르는 부분이 있어서 보면서 배웠습니다!! 몇가지 수정사항이 있어서 남깁니다.