-
Notifications
You must be signed in to change notification settings - Fork 44
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
[김현서] Week15 #479
The head ref may contain hidden characters: "part3-\uAE40\uD604\uC11C-week15"
[김현서] Week15 #479
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.
수고하셨습니다 :)
data: { | ||
id: number; | ||
title: string; | ||
created_at: string; | ||
url: string; | ||
description?: string; | ||
image_source?: string; | ||
}[]; |
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.
data: {} 로 오는 건 보통 서버에서 오는 응답인 경우가 많은데 이 경우엔 generic 함수를 이용해서 처리하는 경우가 많습니다!
https://velog.io/@ctdlog/Axios-Response-with-generic#%EC%99%9C-%EA%B8%B0%EB%B3%B8-response-%ED%83%80%EC%9E%85%EC%9D%84-%EB%B0%94%EA%BF%94%EC%84%9C-%EC%82%AC%EC%9A%A9%ED%95%A0%EA%B9%8C%EC%9A%94
}[]; | ||
} | ||
|
||
export async function useFetchLinks(userId: number, folderId: number) { |
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.
use 로 시작하는 훅의 경우 pages 말고 hooks 폴더에 따로 묶어주심 좋을 거 같아요!
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.
useFetchLink 랑 되게 비슷한 구조라 공통화해봐도 좋을 거 같아요!
|
||
interface CardListProps { | ||
isFolderPage: boolean; | ||
userId?: number | null; | ||
folderId?: string | string[] | null | undefined; |
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.
folderId 의 타입이 너무 많은 거 같아요! 최대한 로직에 맞게 줄여보면 좋을 거 같습니다!
let url = `/users/${userId}/links`; | ||
if (folderId) { | ||
url += `?folderId=${folderId}`; | ||
} |
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.
let url = `/users/${userId}/links`; | |
if (folderId) { | |
url += `?folderId=${folderId}`; | |
} | |
�const url = `/users/${userId}/links` + (folderId ? `?folderId=${folderId}` : ''); |
const 로 쓸 수 있는 것들은 최대한 const 로 써주면 좋습니다!
(link.url && link.url.toLowerCase().includes(lowerSearch)) || | ||
(link.title && link.title.toLowerCase().includes(lowerSearch)) || | ||
(link.description && | ||
link.description.toLowerCase().includes(lowerSearch)) |
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.
이 부분만 따로 떼서 메서드를 만들거나 아니면 util 함수로 빼도 괜찮을 거 같아요!
selectedFolder | ||
? folders.find( | ||
(folder: { id: any }) => folder.id === selectedFolder | ||
)?.name | ||
: "전체" |
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.
render 부에서 계산해주시보다 위에서 계산하고, render 부에서는 display 만 하시는 걸 추천드려요!
const userData: User = res.data.data[0]; | ||
setCurrentUser(userData); | ||
} | ||
|
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.
getUser 부분이 계속 반복되는 거 같아요! 보면 따로 상태가 있는 거 같진 않아서 util 로 빼면 좋을 거 같아요!
요구사항
기본
심화
주요 변경사항
멘토에게