Skip to content

Commit

Permalink
fix wrong useEffect placement
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Nov 9, 2023
1 parent 57c2a54 commit aca420c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/pages/common/components/FeedItem/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,18 @@ const FeedItem = forwardRef<FeedItemRef, FeedItemProps>((props, ref) => {
);
useFeedItemSubscription(item.id, commonId, onFeedItemUpdate);

useEffect(() => {
if (
feedItemFollow.isUserFeedItemFollowDataFetched &&
!feedItemFollow.userFeedItemFollowData
) {
onFeedItemUnfollowed?.(item.id);
}
}, [
feedItemFollow.isUserFeedItemFollowDataFetched,
feedItemFollow.userFeedItemFollowData,
]);

if (
shouldCheckItemVisibility &&
!checkIsItemVisibleForUser(
Expand Down Expand Up @@ -117,18 +129,6 @@ const FeedItem = forwardRef<FeedItemRef, FeedItemProps>((props, ref) => {
onUserSelect,
};

useEffect(() => {
if (
feedItemFollow.isUserFeedItemFollowDataFetched &&
!feedItemFollow.userFeedItemFollowData
) {
onFeedItemUnfollowed?.(item.id);
}
}, [
feedItemFollow.isUserFeedItemFollowDataFetched,
feedItemFollow.userFeedItemFollowData,
]);

if (item.data.type === CommonFeedType.Discussion) {
return <DiscussionFeedCard {...generalProps} />;
}
Expand Down

0 comments on commit aca420c

Please sign in to comment.