Skip to content

Commit 06da868

Browse files
committed
Refactor: 좋아요 코드 간소화 #65
1 parent 92b276c commit 06da868

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

hooks/mutations/useLikeBoard.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ export default function useLikeBoard() {
2020
[queryKeys.BOARD_LIST],
2121
(oldData) => {
2222
if (oldData) {
23-
const updatedData = { ...oldData };
24-
const updatedBoard = updatedData.content?.find(
23+
const updatedBoard = oldData.content?.find(
2524
(board) => board.id === boardId,
2625
);
2726
if (updatedBoard) {
2827
updatedBoard.boardLiked = true;
2928
}
30-
return updatedData;
3129
}
3230
return oldData;
3331
},

hooks/mutations/useUnlikeBoard.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@ export default function useUnlikeBoard() {
2020
[queryKeys.BOARD_LIST],
2121
(oldData) => {
2222
if (oldData) {
23-
const updatedData = { ...oldData };
24-
const updatedBoard = updatedData.content?.find(
23+
const updatedBoard = oldData.content?.find(
2524
(board) => board.id === boardId,
2625
);
2726
if (updatedBoard) {
2827
updatedBoard.boardLiked = false;
2928
}
30-
return updatedData;
3129
}
3230
return oldData;
3331
},

0 commit comments

Comments
 (0)