-
Notifications
You must be signed in to change notification settings - Fork 0
8회차 과제 - 김정운 #2
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?
8회차 과제 - 김정운 #2
Conversation
| const sortById = (list) => list.sort((a, b) => a.id - b.id); | ||
|
|
||
| const addWatched = (movie) => { | ||
| const addWatchedList = (movie) => { | ||
| setWatched((prev) => sortById([...prev, movie])); | ||
| setMovies((prev) => sortById(prev.filter((m) => m.id !== movie.id))); | ||
| }; |
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.
영화를 오름차순으로 정렬하고, 제거 후 원래 리스트에 추가되도록 코드를 깔끔히 잘 작성하셨네요!
RSH0770
left a comment
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.
코드가 전반적으로 구조화가 잘 되어있어서 금방 이해할 수 있었습니다!
| loadMovies(); | ||
| }, []); | ||
|
|
||
| const sortById = (list) => list.sort((a, b) => a.id - b.id); |
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.
sortById라는 함수를 통해 인덱스를 삭제하면 해당 함수 호출을 통한 정렬을 편리하게 구현하셨군요!
| if (loading) { | ||
| return ( | ||
| <div> | ||
| <div className="text-center border bg-gray-700 text-white font-bold text-2xl p-3"> | ||
| Movie List | ||
| </div> | ||
| <div className="mb-7 text-center text-xl font-bold mt-10"> | ||
| Loading... | ||
| </div> | ||
| <div className="text-center border bg-gray-700 text-white font-bold text-xl p-3"> | ||
| Footer | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
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.
로딩 중일 때의 화면도 구현하는 것도 좋은 것 같습니다!
신경써서 구현한 부분
함수 소개
addWatchedList: 시청한 영화 목록에 추가addToWatchList: 볼 영화 목록에 추가removeWatchedList: 시청한 영화 목록에서 제거removeToWatchList: 볼 영화 목록에서 제거sortById: 오름차순 정렬궁금한 점