Skip to content

Commit

Permalink
refactor(TemplatePage): useLike 훅에서 setLikesCount 방식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
vi-wolhwa committed Sep 25, 2024
1 parent 58362c2 commit 23d2458
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions frontend/src/pages/TemplatePage/hooks/useLike.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export const useLike = ({ templateId, initialLikesCount, initialIsLiked }: UseLi
try {
if (!isLiked) {
setIsLiked(true);
setLikesCount(initialLikesCount + 1 - +initialIsLiked);
setLikesCount((prev) => prev + 1);
await likeTemplate(templateId);
} else {
setIsLiked(false);
setLikesCount(initialLikesCount - 1 + +!initialIsLiked);
setLikesCount((prev) => prev - 1);
await dislikeTemplate(templateId);
}
} catch (error) {
Expand Down

0 comments on commit 23d2458

Please sign in to comment.