diff options
author | eug-vs <eug-vs@keemail.me> | 2020-07-05 14:27:40 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-07-05 14:27:40 +0300 |
commit | c02ba097faa134266dc226be9bccc2070855e2b7 (patch) | |
tree | fdf7e9b933fc52f030d148e3a4d3c35202209d69 /src/pages | |
parent | 1a36aadf83ccbb5ff86f027cc9109bfa9dbe75bc (diff) | |
download | which-ui-c02ba097faa134266dc226be9bccc2070855e2b7.tar.gz |
fix: display loader correctly
Diffstat (limited to 'src/pages')
-rw-r--r-- | src/pages/ProfilePage/ProfilePage.tsx | 5 |
1 files changed, 4 insertions, 1 deletions
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} /> - <Feed polls={[...polls]} /> + {isPollsLoading ? <Feed polls={[]} /> : (polls.length > 0 && <Feed polls={polls} />)} </Container> ); }; |