-
Notifications
You must be signed in to change notification settings - Fork 217
[10기 이재훈] ToDoList CRUD #213
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
base: main
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.
재사용, 이벤트위임, 결합에 대해서 리뷰 남겼습니다:)
$todoInput; | ||
$todoList; | ||
constructor(){ | ||
const toDoInputTarget = document.querySelector("#new-todo-title"); |
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.
반복되는 document.querySelector를 유틸함수로 빼서 재사용해보는것도 좋을꺼 같아요.
$target; | ||
constructor(target){ | ||
this.$target = target; | ||
this.setState({ |
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.
state를 초기화하는 방식이 TodoInput과 다릅니다.
this.$todoList = new ToDoList(toDoListTarget); | ||
} | ||
addToDoItem(itemTitle){ | ||
this.$todoList.addItem(itemTitle); |
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.
todoList와 todoInput이 강하게 묶여 있습니다. observer 패턴형태를 참고해서 수정해도 좋을꺼 같습니다.
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.
넵넵 todoList 와 todoInput을 상위에서 묶음으로써 todoList 컴포넌트와 todoInput 컴포넌트의 state를 따로 관리하였고, 그로인해서 state 초기화가 달랐던것입니다! observer 패턴을 잘 모르지만 공부해서 반영해보도록 하겠습니다!
addToggleEvent(){ | ||
const toggleComponents = this.$target.querySelectorAll('.toggle'); | ||
const {items} = this.state; | ||
toggleComponents.forEach((element,idx) => { |
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.
모든 토글에 리스너를 등록하는 방법 대신 이벤트위임을 통해 부모 노드에만 이벤트를 등록하는 방법을 고려해보세요.
[(https://ko.javascript.info/event-delegation)]
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.
형남님이 코드리뷰를 잘해주신것 같습니다..
잘 구현하신것 같아요. 굳이 뽑자면 화살표함수가 어떤 부분은 띄어쓰기가 되어있고 안되어있는게 있는데 그 부분만 동일하게 해주면 좋을 것 같습니다! 좋은코드 잘읽었습니다 감사합니다.!!!!
삭제까지밖에 구현하지 못했습니다 ㅠㅠ 얼른해서 마무리 짓겠습니다!