-
Notifications
You must be signed in to change notification settings - Fork 5
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
✨ 좋아요 싫어요 낙관적 업데이트 적용 #322
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프로젝트 끝나자마자 바로 리팩토링 열심히 하시는 효중님... 👍 진짜 멋지십니다 저도 부지런히 리팩토링 해야겠어요 !!!
await queryClient.invalidateQueries(['post', initPost._id]) | ||
}, | ||
}, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useMutation을 활용한 낙관적 업데이트..! 공식 문서에 있는 거 보긴 했지만 반영은 못했는데 저도 팔로우 관련해서 리팩토링 할 때 잘 참고해보겠습니다 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
되게 편하게 적용할 수 있더라고요 !! 화이팅임니다.!!
src/queries/likes/index.ts
Outdated
initDisLikePost: Post | ||
} | ||
|
||
export function useLikeQuery(postId: string, initPost: Post) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋아요 포스트를 가져오는 쿼리같은데 포스트를 가져온다는 의미를 이름에 담아보면 어떨까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오오 좋습니당
}) | ||
.finally(() => { | ||
setLoading(false) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isLikePostFetching을 걸어줘서 이게 필요 없어진 건가요 ?? 👍👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
맞아요! !!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋네요!!
src/queries/likes/index.ts
Outdated
|
||
export function useLikeMutate({ initPost, initDisLikePost }: useLikeProps) { | ||
const queryClient = useQueryClient() | ||
const { currentUser } = useCurrentUser() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useAuth()로 대체하기로 하지 않았나요?? 그것도 그렇지만 여기서 의존적으로 불러오는 것보다는 전달받아 사용하면 좋을 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오오그게 더 좋겠네욤
- 목적
관련 이슈: #
- 주요 변경 사항
기타 사항 (선택)
- 스크린샷 (선택)
chrome-capture-2023-9-4.webm