From 987c050faa5353ae2f250d82055d6685fefa58f7 Mon Sep 17 00:00:00 2001
From: ilyayudovin <ilyayudovin123@gmail.com>
Date: Sun, 14 Jun 2020 20:54:02 +0300
Subject: add useEffect to get requests

---
 src/pages/ProfilePage/ProfilePage.tsx | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

(limited to 'src/pages/ProfilePage/ProfilePage.tsx')

diff --git a/src/pages/ProfilePage/ProfilePage.tsx b/src/pages/ProfilePage/ProfilePage.tsx
index 1dd71d3..984fb1e 100644
--- a/src/pages/ProfilePage/ProfilePage.tsx
+++ b/src/pages/ProfilePage/ProfilePage.tsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useState,useEffect } from 'react';
 import { User, Poll } from '../../types';
 import ProfileInfo from './ProfileInfo';
 import Feed from '../../components/Feed/Feed';
@@ -13,13 +13,18 @@ const ProfilePage: React.FC<PropTypes> = ({ logOut, id }) => {
   const [userInfo, setUserInfo] = useState<User>();
   const [polls, setPolls] = useState<Poll[]>([]);
 
-  get(`/users/${id}`).then(response => {
-    setUserInfo(response.data);
-  });
+  useEffect(() => {
+    get(`/users/${id}`).then(response => {
+      setUserInfo(response.data);
+    });
+  },[]);
+
+  useEffect(() => {
+    get(`/profiles/${id}`).then(response => {
+      setPolls(response.data);
+    });
+  },[]);
 
-  get(`/profiles/${id}`).then(response => {
-    setPolls(response.data);
-  });
 
   return (
     <>
-- 
cgit v1.2.3

