-
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
[허찬욱] week11 #370
The head ref may contain hidden characters: "part2-\uD5C8\uCC2C\uC6B1-week11"
[허찬욱] week11 #370
Conversation
수고 하셨습니다 ! 위클리 미션 하시느라 정말 수고 많으셨어요. |
import { useAsync } from "sharing/util"; | ||
import { axiosInstance } from "sharing/util"; | ||
|
||
export const useGetFolder = () => { |
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.
굳굳 ! API마다 커스텀 훅을 만드셨군요 ! 👍
@@ -0,0 +1,14 @@ | |||
import { mapLinksData } from "link/util-map"; | |||
|
|||
export const mapFolderData = (folder) => { |
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 useGetFolder = () => { | ||
const getFolder = () => axiosInstance.get("sample/folder"); | ||
const { loading, error, data } = useAsync(getFolder); |
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.
loading
, error
, data
등 비동기에 필요한 상태관리가 컴팩트하게 잘 이루어져있군요 ! 👍
const { loading, error, data } = useAsync(getFolders); | ||
|
||
const folders = data?.data ?? []; | ||
const sortedFolders = folders.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.
정렬은 함수로 따로 구분할 수 있을 것 같아요.
useGetFolders
의 책임이 두 가지 이상이 되는 것 같아서요 ! 물론, 모두 다 코드를 분리하게되면 생산성이 좋지 못하기에 참고 정도로만 봐주시면 될 것 같습니다 😊
|
||
const cx = classNames.bind(styles); | ||
|
||
export const AddFolderButton = ({ onClick }) => { |
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.
해당 컴포넌트는 IconButton
과 같이 확장성 있는 컴포넌트로 만들어볼 수 있을 것 같아요:
export const AddFolderButton = ({ onClick }) => { | |
export const IconButton = ({ onClick, icon }) => { |
import { CardContent } from "sharing/ui-card-content"; | ||
import { CardImage } from "sharing/ui-card-image"; | ||
|
||
export const ReadOnlyCard = ({ url, imageSource, alt, elapsedTime, description, createdAt }) => { |
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.
훌륭합니다 !
ui
계층을 분리하여 Card
를 사용하고 합성하여 새로운 ReadOnlyCard
를 만드셨군요 ! 👍👍
return ( | ||
<div className={cx("container")}> | ||
<input className={cx("input")} type="search" placeholder="링크를 검색해 보세요." /> | ||
<img src={SEARCH_IMAGE} alt="검색창인 것을 알려주는 돋보기 아이콘" className={cx("icon")} /> |
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.
alt
가 자세하고 좋아요 🥺🥺🥺
const { data: folders } = useGetFolders(); | ||
const [selectedFolderId, setSelectedFolderId] = useState(ALL_LINKS_ID); | ||
const { data: links, loading } = useGetLinks(selectedFolderId); | ||
const cardList = useMemo(() => { |
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.
useMemo
를 활용한 최적화 👍👍👍
return ( | ||
<CardList> | ||
{links.map((link) => ( | ||
<EditableCard key={link?.id} {...link} /> |
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.
key
값이 매우 적절합니다 !
<span className={cx("copyright")}>{TEXT.codeit}</span> | ||
<div className={cx("links")}> | ||
<a className={cx("link")} href={ROUTE.개인정보처리방침}> | ||
{TEXT.privacyPolicy} |
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.
혹시 TEXT
라는 상수를 따로 정의한 이유가 있으실까요?
상수로 파일을 분리하면서 이득을 얻을 수 있는게 무엇이 있을지 궁금합니다 !
수고 많으셨습니다 찬욱님 ! ㅎㅎㅎ |
요구사항
기본
심화
주요 변경사항
스크린샷
멘토에게