From a56ed602a4149a3e19ac58c84c51e0eb108358c2 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 4 Jul 2020 00:35:39 +0300 Subject: fix: display skeleton correctly --- src/pages/ProfilePage/ProfilePage.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/pages/ProfilePage/ProfilePage.tsx') diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index ba4db7d..3beeb00 100644 --- a/src/pages/ProfilePage/ProfilePage.tsx +++ b/src/pages/ProfilePage/ProfilePage.tsx @@ -15,14 +15,15 @@ const ProfilePage: React.FC = () => { const [totalVotes, setTotalVotes] = useState(0); const { page, navigate } = useNavigate(); const { user } = useAuth(); - const [isLoading, setIsLoading] = useState(false); + const [isInfoLoading, setIsInfoLoading] = useState(false); useEffect(() => { const id = page?.id || user?._id; - setIsLoading(true); + setIsInfoLoading(true); if (id) { get(`/users/${id}`).then(response => { setUserInfo(response.data); + setIsInfoLoading(false); }); get(`/profiles/${id}`).then(response => { setPolls([]); @@ -33,7 +34,6 @@ const ProfilePage: React.FC = () => { return total + left.votes + right.votes; }, 0 )); - setIsLoading(false); }); } else navigate('auth'); }, [navigate, page, user]); @@ -45,7 +45,7 @@ const ProfilePage: React.FC = () => { setUserInfo={setUserInfo} savedPolls={polls.length} totalVotes={totalVotes} - loading={isLoading} + isLoading={isInfoLoading} /> -- cgit v1.2.3