diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/Feed/Feed.tsx | 6 | ||||
-rw-r--r-- | src/pages/ProfilePage/ProfilePage.tsx | 8 |
2 files changed, 8 insertions, 6 deletions
diff --git a/src/components/Feed/Feed.tsx b/src/components/Feed/Feed.tsx index 5805e35..bf3c5b7 100644 --- a/src/components/Feed/Feed.tsx +++ b/src/components/Feed/Feed.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { Poll } from 'which-types'; import { WindowScroller, AutoSizer, List } from 'react-virtualized'; import PollCard from '../PollCard/PollCard'; -import Loading from '../Loading/Loading'; + interface PropTypes { polls: Poll[]; @@ -26,7 +26,7 @@ const Feed: React.FC<PropTypes> = ({ polls }) => { ); }; - const list = ( + return ( <WindowScroller> {({ height, @@ -57,8 +57,6 @@ const Feed: React.FC<PropTypes> = ({ polls }) => { )} </WindowScroller> ); - - return polls.length ? list : <Loading />; }; export default Feed; diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx index 9e00784..db27d25 100644 --- a/src/pages/ProfilePage/ProfilePage.tsx +++ b/src/pages/ProfilePage/ProfilePage.tsx @@ -5,6 +5,7 @@ import { Container } from '@material-ui/core'; import ProfileInfo from './ProfileInfo'; import Feed from '../../components/Feed/Feed'; +import Loading from '../../components/Loading/Loading'; import { useAuth } from '../../hooks/useAuth'; import { useUser, useProfile } from '../../hooks/APIClient'; @@ -15,7 +16,7 @@ const ProfilePage: React.FC = () => { const { user } = useAuth(); const { data: userInfo, mutate: setUserInfo } = useUser(username); - const { data: polls } = useProfile(userInfo?._id); + const { data: polls, isValidating } = useProfile(userInfo?._id); useEffect(() => { if (!username) { @@ -43,7 +44,10 @@ const ProfilePage: React.FC = () => { savedPolls={polls.length} totalVotes={totalVotes} /> - <Feed polls={polls} /> + {!polls.length && isValidating + ? <Loading /> + : <Feed polls={polls} /> + } </Container> ); }; |