diff --git a/front/src/component/follow/FollowList.jsx b/front/src/component/follow/FollowList.jsx index aa0b7830..42d9a4cc 100644 --- a/front/src/component/follow/FollowList.jsx +++ b/front/src/component/follow/FollowList.jsx @@ -48,7 +48,6 @@ const FollowListContainer = styled.div` `; function FollowList({ myFollowing }) { - console.log(myFollowing.boards); return ( diff --git a/front/src/component/follow/FollowUserCard.jsx b/front/src/component/follow/FollowUserCard.jsx index 5b763ff3..123ae732 100644 --- a/front/src/component/follow/FollowUserCard.jsx +++ b/front/src/component/follow/FollowUserCard.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import styled from 'styled-components'; import { Link } from 'react-router-dom'; import { useSelector, useDispatch } from 'react-redux'; @@ -118,6 +118,7 @@ const FollowListLeftSide = styled.div` `; function FollowUserCard({ myFollowing }) { + const [isFollow, setIsFollow] = useState(!!myFollowing.follow); const dispatch = useDispatch(); const isLogin = useSelector(state => state.login.isLogin); const cookieAccountId = Number(localStorage.getItem('accountId')); @@ -125,8 +126,17 @@ function FollowUserCard({ myFollowing }) { const followHandler = () => { if (isLogin) { - postDetailFollowApi(myFollowing.id); - window.location.reload(); + postDetailFollowApi(myFollowing.id) + .then(res => { + if (res === 'SUCCESS') { + setIsFollow(true); + } else { + setIsFollow(false); + } + }) + .catch(err => { + console.log(err); + }); } else { dispatch(loginModalActions.openLoginModal()); } @@ -148,7 +158,7 @@ function FollowUserCard({ myFollowing }) {
  • {cookieAccountId === myFollowing.id ? (
    - ) : !myFollowing.follow ? ( + ) : !isFollow ? ( 팔로우