Skip to content

Commit

Permalink
Fixed fetch favorite post status code
Browse files Browse the repository at this point in the history
  • Loading branch information
MeetDOD committed Aug 9, 2024
1 parent 02b35f9 commit ddbb40f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions frontend/src/components/PostCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ const PostCard = ({ post, onDelete, currentUser }: Props) => {
useEffect(() => {
const fetchFavoriteStatus = async () => {
try {
if (!currentUser) {
return;
}
const token = localStorage.getItem("token");
if (!token) {
return;
Expand All @@ -56,9 +59,10 @@ const PostCard = ({ post, onDelete, currentUser }: Props) => {
toast.error("Failed to fetch favorite status");
}
};

fetchFavoriteStatus();
}, [post.id]);
}, [post.id, currentUser]);


const handleAddToFavorite = async (event: React.MouseEvent) => {
event.stopPropagation();
Expand Down

0 comments on commit ddbb40f

Please sign in to comment.