Skip to content

Commit

Permalink
Refactor: 좋아요 코드 간소화 #65
Browse files Browse the repository at this point in the history
  • Loading branch information
jiyeeeah committed Oct 23, 2023
1 parent 92b276c commit 06da868
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions hooks/mutations/useLikeBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ export default function useLikeBoard() {
[queryKeys.BOARD_LIST],
(oldData) => {
if (oldData) {
const updatedData = { ...oldData };
const updatedBoard = updatedData.content?.find(
const updatedBoard = oldData.content?.find(
(board) => board.id === boardId,
);
if (updatedBoard) {
updatedBoard.boardLiked = true;
}
return updatedData;
}
return oldData;
},
Expand Down
4 changes: 1 addition & 3 deletions hooks/mutations/useUnlikeBoard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ export default function useUnlikeBoard() {
[queryKeys.BOARD_LIST],
(oldData) => {
if (oldData) {
const updatedData = { ...oldData };
const updatedBoard = updatedData.content?.find(
const updatedBoard = oldData.content?.find(
(board) => board.id === boardId,
);
if (updatedBoard) {
updatedBoard.boardLiked = false;
}
return updatedData;
}
return oldData;
},
Expand Down

0 comments on commit 06da868

Please sign in to comment.