feat: follow state sync hook, store, api 추가 #297
Merged
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.
🤔 어떤 문제가 발생했나요?
🎉 어떻게 해결했나요?
타인의 id 리스트, 단일 id에 대한 본인의 follow 여부를 조회하고 변경할 수 있는 훅을 개발합니다
사용법
사용법은 다음과 같습니다.
useMemberFollowingState
훅의useSyncFollowingListState
를 꺼내와 사용합니다.memberIdList를 받아 한번에 api를 호출하고, memberID 기준의 query 데이터에 캐싱됩니다.
member 단일의 isFollowing의 상태는 다음과 같습니다
useMemberFollowingState
훅의useMemberIsFollowing
을 꺼내와 isFollowing 상태를 사용합니다.toggle하고자 할 때,
toggleFollow
함수를 꺼내와 사용합니다.-> toggleFollow는 우선적으로 보여지는 상태를 변경하고 > 이후에 api를 호출합니다 (상태 우선 업데이트)
📷 이미지 첨부 (Option)