diff options
Diffstat (limited to 'src/pages/ProfilePage/ProfilePage.tsx')
-rw-r--r-- | src/pages/ProfilePage/ProfilePage.tsx | 19 |
1 files changed, 12 insertions, 7 deletions
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 ( <> |