aboutsummaryrefslogtreecommitdiff
path: root/src/pages/ProfilePage/ProfilePage.tsx
diff options
context:
space:
mode:
authorilyayudovin <ilyayudovin123@gmail.com>2020-06-14 20:54:02 +0300
committerilyayudovin <ilyayudovin123@gmail.com>2020-06-14 20:54:02 +0300
commit987c050faa5353ae2f250d82055d6685fefa58f7 (patch)
treed4c40608f40ed27a7d8cb908cdae225bb86e50ae /src/pages/ProfilePage/ProfilePage.tsx
parent65e41d1d8a3844a6d7268340f5d88b5957e2355d (diff)
downloadwhich-ui-987c050faa5353ae2f250d82055d6685fefa58f7.tar.gz
add useEffect to get requests
Diffstat (limited to 'src/pages/ProfilePage/ProfilePage.tsx')
-rw-r--r--src/pages/ProfilePage/ProfilePage.tsx19
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 (
<>