Skip to content
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 #364

Merged

Conversation

LeeSG98
Copy link
Collaborator

@LeeSG98 LeeSG98 commented Apr 28, 2024

요구사항

기본

  • 케밥 버튼을 누르면 팝오버가 보이게 해주세요.
  • 폴더에 있는 버튼 “폴더 추가”, “공유”, “이름 변경”, “삭제”
팝오버에 있는 버튼 “삭제하기”, “폴더에 추가”
클릭시 해당하는 모달이 뜨게 해주세요.
  • 링크를 입력하고 “추가하기” 버튼을 누르면 “폴더에 추가” 모달이 뜨게 해주세요.

주요 변경사항

스크린샷

image

image

image

image

멘토에게

  • 설정을 잘못 건드려서 파일을 통째로 지우고 다시 생성하였습니다.
  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

@LeeSG98 LeeSG98 requested a review from Ahseo April 28, 2024 13:50
@LeeSG98 LeeSG98 changed the title 이순구[WEEK11] [이순구]WEEK11 Apr 28, 2024
Copy link
Collaborator

@Ahseo Ahseo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

파일이 날아가서 그런지 변경사항이아니라 새로 작성된듯한 내용들이 엄청 많아서..ㅎㅎ 리뷰가 조금 어려웠네요ㅠ죄송합니다!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root에서 hook, component, layout(?)을 나뉘어서 관리하는 것이 좋을 것 같아요! 이렇게되면 아무래도 전체에서 공통으로 쓰이는 컴포넌트 및 hook들을 관리하기 어려워져서요 ㅎㅎ src/components, src/hooks 이런식은 어떨까요?

Comment on lines +27 to +38
const closeModal = () => setCurrentModal(null);
const handleKeyDown = (event) => {
if (event.key === "Escape") {
closeModal();
}
};
const handleKakaoClick = () => {
shareKakao({ url: shareLink, ...KAKAO_SHARE_DATA });
};
const handleFacebookClick = () =>
window.open(`http://www.facebook.com/sharer.php?u=${shareLink}`);
const handleLinkCopyClick = () => copyToClipboard(shareLink);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

함수 정의를 잘 해주셨네요! ㅎㅎ

// eslint-disable-next-line react-hooks/exhaustive-deps
}, [folderId]);

const mapDataFormat = ({ id, created_at, url, image_source, title, description }) => ({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convertFormat~~ 과 같이 동적인 함수로 명명을 정의하면 어떨까요?


useEffect(() => {
execute();
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기가 조금 애매하다면

if (folderId) execute();

이렇게 작성하면 어떨까요?

const { data: folders } = useGetFolders();
const cardListRef = useRef(null);
const [selectedFolderId, setSelectedFolderId] = useState(null);
const [currentModal, setCurrentModal] = useState(null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분이 항상 나오는데 이를 useModal로 빼보면 어떨까요~? onOpen, onClose 등을 리턴하는 훅으로요.

<EditableCard
key={link?.id}
{...link}
popoverPosition={getPopoverPosition(index)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

호출이 각 카드가 렌더링 될 때마다 일어나는 것이 좀 안좋을 것 같아요! 특히 위에서 state가 바뀌면 계속 호출이 일어나는 것이어서요.
해당 함수를 EditableCard안에 useCallback으로 정의하면 어떨까요~?

selectedLinkUrl={selectedLinkUrl}
selectedFolderId={selectedFolderId}
setSelectedFolderId={setSelectedFolderId}
onAddClick={() => {}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 callback을 빈 부분으로 넘기는 것이 어떤 이유일까요~?

Comment on lines +14 to +18
const handleKeyDown = (event) => {
if (event.key === "Escape") {
closeModal();
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handlekeyDown안에서 closeModal하는 부분도 항상 존재하네요! 이 부분도 useModal안으로 옮겨도 좋겠네요.

cardList={
<CardList>
{links?.map((link) => (
<ReadOnlyCard key={link?.id} {...link} />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional한 값이라면 아예 index로 key를 설정해도 좋을 것 같아요!

Comment on lines +20 to +22
if (onBackdropClick) {
onBackdropClick(event);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onBackdropClick?.(event) 라고 써도 될 것 같아요!

@Ahseo Ahseo merged commit b9e12c3 into codeit-bootcamp-frontend:part2-이순구 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants