From 490904d9299df636134b82d5507e629f570a1791 Mon Sep 17 00:00:00 2001
From: ilyayudovin <ilyayudovin123@gmail.com>
Date: Sat, 27 Jun 2020 17:53:31 +0300
Subject: change avata image right after submit

---
 src/pages/ProfilePage/ProfilePage.tsx | 9 +++++----
 1 file changed, 5 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 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} />
     </>
   );
 };
-- 
cgit v1.2.3

