Week7/celine m2#72
Open
yoons-art wants to merge 31 commits into
Open
Conversation
feat: 1주차 미션 완료
Week3/celine m2
Week3/celine m3
Week4/celine m2
Week4/celine m3
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
yewon20804
reviewed
May 19, 2026
Collaborator
yewon20804
left a comment
There was a problem hiding this comment.
7주차 미션2 확인했습니다 ! 낙관적 업데이트 개념을 이해하고 좋아요 기능을 구현해보는거였는데요! 😀
코멘트 확인 부탁드립니다 ~
1. usePostLike.ts & useDeleteLike.ts — onError에서 롤백 데이터
// ❌ 현재
onError: (err, newLp, context) => {
queryClient.setQueryData(
[QUERY_KEY.lps, newLp.lpId],
context?.previousLpPost?.data?.id, // ← 잘못된 부분
)
},
// ✅ 수정 — previousLpPost 전체를 넣어야 이전 상태로 안전하게 롤백됩니다
onError: (err, newLp, context) => {
queryClient.setQueryData(
[QUERY_KEY.lps, newLp.lpId],
context?.previousLpPost, // ← 수정
)
},
롤백 시에는 수정된 일부 값만 아니라 이전 데이터 전체를 복원해줘야, 에러 발생 시 원래 상태로 안전하게 되돌릴 수 있을 것 같습니다!
2. useDeleteLike.ts — 삭제 로직이 없음!
// ❌ 현재 — 추가/제거 로직이 postLike와 동일
if (likeIndex >= 0) {
previousLpPost?.data?.likes.splice(likeIndex, 1);
} else {
const newLike = { userId, lpId: lp.lpId } as Likes;
previousLpPost?.data?.likes.push(newLike); // ← 여기
}
// ✅ 수정
if (likeIndex >= 0) {
previousLpPost?.data?.likes.splice(likeIndex, 1);
}
useDeleteLike는 좋아요를 제거하는 로직인데, 현재 onMutate가 usePostLike와 동일하게 작성되어 있어서 둘 다 좋아요를 추가하는 방향으로 동작하고 있는 것 같습니다! useDeleteLike는 삭제되도록 수정 사항 확인해주세요 😀
미션 1에 달아드린 lp.ts — URL에 백틱() 대신 따옴표 , LpDetailPage.tsx — 로딩/에러 조건 오류도 같이 해결 하면 좋을 것 같습니다 :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📚 주차 / 미션
📌 작업 내용
✨ 상세 작업 내용
✅ 체크리스트