Skip to content

Commit 76ca062

Browse files
committed
fix: set initial state for follow
velog devs wants to sleep
1 parent 6a83979 commit 76ca062

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/components/common/FollowButton.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@ const FollowButton: React.FC<PostFollowButtonProps> = ({
2525
const [unfollow, { loading: loadingUnfollowUser }] =
2626
useMutation(UNFOLLOW_USER);
2727

28-
const [initialFollowState, setInitialFollowState] = React.useState<boolean>();
29-
const [currentFollowState, setCurrentFollowState] = React.useState<boolean>();
28+
const [initialFollowState, setInitialFollowState] = React.useState<boolean>(
29+
!!followed,
30+
);
31+
const [currentFollowState, setCurrentFollowState] = React.useState<boolean>(
32+
!!followed,
33+
);
3034

3135
const [buttonText, setButtonText] = React.useState('팔로잉');
3236

@@ -97,6 +101,8 @@ const FollowButton: React.FC<PostFollowButtonProps> = ({
97101
setCurrentFollowState(followed);
98102
}, [followed]);
99103

104+
if (followed === undefined) return null;
105+
100106
return (
101107
<FollowButtonBlock
102108
data-testid="follow-btn"

0 commit comments

Comments
 (0)