Sort PR#5
Conversation
|
@SeungJoo-Han is attempting to deploy a commit to the KUCC Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| for (let i = 0; i<sortArray.length ; i++){ | ||
| if(sortArray[i].difficulty === "hard"){ | ||
| newSortArray.push(sortArray[i]) | ||
| }} |
There was a problem hiding this comment.
const difficultyList = ["easy", "medium", "hard"] 라는 배열을 만들어서 중복을 줄일 수 있을 거 같아요!
| }) No newline at end of file | ||
| }) | ||
|
|
||
| export const sortCourseState = atom<string | null>({ |
There was a problem hiding this comment.
sortCourseState와 같은 경우에는 일반적인 string 보다는 특수한 string이 오는 케이스이니, string literal을 쓰면 더 좋을 거 같아요. ex ) type SortCourse = "타이틀순" | "학점순" | "난이도순"
| '타이틀순', | ||
| '학점순', | ||
| '난이도순', | ||
| ]; No newline at end of file |
There was a problem hiding this comment.
이런식으로 상수 정리하시는 습관 너무 좋습니다 :)
There was a problem hiding this comment.
아까 타입과 관련해서 type SortCourse = "타이틀순" | "학점순" | "난이도순"라고 썼었는데, 이런식으로 상수로 정리되어 있다면 배열을 as const로 만들고 배열에서 string literal 타입을 뽑아오는 것도 좋은 패턴입니다!
|
difficultyList 만들어서 수정했습니다 |
타이틀/학점/난이도 순 정렬 버튼입니다.
버튼 간격이 없어서 style 조금 수정했는데 확인해보시고 바꾸시려면 바꾸시는게 좋을거 같아요.