-
Notifications
You must be signed in to change notification settings - Fork 8
Sort PR #5
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?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const difficultyList = ["easy", "medium", "hard"]
라는 배열을 만들어서 중복을 줄일 수 있을 거 같아요!
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.
수정 했어요!
}) | ||
|
||
export const sortCourseState = atom<string | null>({ |
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.
sortCourseState와 같은 경우에는 일반적인 string 보다는 특수한 string이 오는 케이스이니, string literal을 쓰면 더 좋을 거 같아요. ex ) type SortCourse = "타이틀순" | "학점순" | "난이도순"
'타이틀순', | ||
'학점순', | ||
'난이도순', | ||
]; |
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.
이런식으로 상수 정리하시는 습관 너무 좋습니다 :)
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.
아까 타입과 관련해서 type SortCourse = "타이틀순" | "학점순" | "난이도순"
라고 썼었는데, 이런식으로 상수로 정리되어 있다면 배열을 as const로 만들고 배열에서 string literal 타입을 뽑아오는 것도 좋은 패턴입니다!
difficultyList 만들어서 수정했습니다 |
타이틀/학점/난이도 순 정렬 버튼입니다.
버튼 간격이 없어서 style 조금 수정했는데 확인해보시고 바꾸시려면 바꾸시는게 좋을거 같아요.