aboutsummaryrefslogtreecommitdiff
path: root/src/pages/ProfilePage/ProfilePage.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/ProfilePage/ProfilePage.tsx')
-rw-r--r--src/pages/ProfilePage/ProfilePage.tsx9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx
index b2ca0a0..479fd5c 100644
--- a/src/pages/ProfilePage/ProfilePage.tsx
+++ b/src/pages/ProfilePage/ProfilePage.tsx
@@ -25,7 +25,9 @@ const ProfilePage: React.FC<PropTypes> = ({ logOut, id, navigate,setUser }) => {
useEffect(() => {
get(`/profiles/${id}`).then(response => {
- setPolls(response.data);
+ setPolls([]);
+ setPolls([...response.data]);
+
// const x = response.data.reduce((a: any, c: any) => a.contents.left.votes + c.contents.left.votes);
// const y = response.data.reduce((a: any, c: any) => a.contents.right.votes + c.contents.right.votes);
let sum = 0;
@@ -35,13 +37,12 @@ const ProfilePage: React.FC<PropTypes> = ({ logOut, id, navigate,setUser }) => {
}
setTotalVotes(sum);
});
- }, [id]);
-
+ }, [id, userInfo]);
return (
<>
<ProfileInfo user={userInfo} setUserInfo={setUserInfo} setUser={setUser} logOut={logOut} savedPolls={polls.length} totalVotes={totalVotes}/>
- <Feed polls={polls} navigate={navigate} />
+ <Feed polls={[...polls]} navigate={navigate} />
</>
);
};