From c02ba097faa134266dc226be9bccc2070855e2b7 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 5 Jul 2020 14:27:40 +0300 Subject: fix: display loader correctly --- src/pages/ProfilePage/ProfilePage.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/pages/ProfilePage/ProfilePage.tsx') diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index 3beeb00..34c9efa 100644 --- a/src/pages/ProfilePage/ProfilePage.tsx +++ b/src/pages/ProfilePage/ProfilePage.tsx @@ -16,16 +16,19 @@ const ProfilePage: React.FC = () => { const { page, navigate } = useNavigate(); const { user } = useAuth(); const [isInfoLoading, setIsInfoLoading] = useState(false); + const [isPollsLoading, setIsPollsLoading] = useState(false); useEffect(() => { const id = page?.id || user?._id; setIsInfoLoading(true); + setIsPollsLoading(true); if (id) { get(`/users/${id}`).then(response => { setUserInfo(response.data); setIsInfoLoading(false); }); get(`/profiles/${id}`).then(response => { + setIsPollsLoading(false); setPolls([]); setPolls(response.data); setTotalVotes(response.data.reduce( @@ -47,7 +50,7 @@ const ProfilePage: React.FC = () => { totalVotes={totalVotes} isLoading={isInfoLoading} /> - + {isPollsLoading ? : (polls.length > 0 && )} ); }; -- cgit v1.2.3