Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tlshoon
Copy link

@tlshoon tlshoon commented May 12, 2023

리뷰 남깁니다.

TodoList 기능 잘 구현이 됐습니다. 저도 잘 모르는 부분이 있어서 보면서 배웠습니다!! 몇가지 수정사항이 있어서 남깁니다.

Copy link
Author

@tlshoon tlshoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다!! 로컬스토리지 저장까지 구현해서 올리면 다시 리뷰 남기겠습니다!

Comment on lines +38 to +40
if (e.type === "keypress" && e.key !== "Enter") {
return;
}
Copy link
Author

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);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오타 있어서 수정했습니다

Comment on lines +17 to +23
const updateTodoList = (update) => {
setTodoList(
todoList.map((item) =>
item.id === todoItem.id ? { ...item, ...update(item) } : item
)
);
};
Copy link
Author

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를 생성하는 부분이 반복되고 있습니다. 이 부분을 별도의 함수로 분리했습니다.

Comment on lines -17 to -25
const onChangeCheckbox = () => {
const nextTodoList = todoList.map((item) => ({
...item,
// id 값이 같은 항목의 checked 값을 Toggle 함
checked: item.id === todoItem.id ? !item.checked : item.checked,
}));

setTodoList(nextTodoList);
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateTodoList 함수를 사용하면 이 반복 코드를 줄일 수 있습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant