Skip to content

Commit a44869d

Browse files
committed
refactor: getUser로 posts 가져오기, 오타수정
1 parent b7f7095 commit a44869d

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

src/pages/UserPage/index.jsx

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { useParams } from 'react-router-dom';
44
import { initialUserData } from 'contexts/UserContext/reducer';
55
import { useUserContext } from 'contexts/UserContext';
66
import { getUser } from 'utils/apis/userApi';
7-
import { getUserPosts, getPostData } from 'utils/apis/postApi';
7+
import { getPostData } from 'utils/apis/postApi';
88
import {
99
GRID_INACTIVE,
1010
GRID_ACTIVE,
1111
HEART_INACTIVE,
1212
HEART_ACTIVE,
1313
} from 'utils/constants/icons/names';
14-
import { UserContainter } from './style';
14+
import { UserContainer } from './style';
1515
import UserData from './UserData';
1616
import getUserLevel from 'utils/functions/userLevel/getUserLevel';
1717

@@ -33,23 +33,16 @@ const UserPage = () => {
3333
setCurrentTab(value);
3434
};
3535

36-
const handleGetUserPosts = useCallback(async () => {
37-
if (pageUserId) {
38-
const { data } = await getUserPosts(pageUserId);
39-
setUserPosts(data);
40-
}
41-
}, [pageUserId]);
42-
4336
const handleGetUser = useCallback(async () => {
4437
if (pageUserId) {
4538
const { data } = await getUser(pageUserId);
4639
setUser(data);
4740
const { posts, comments, followers } = data;
4841
const { level } = getUserLevel({ posts, comments, followers });
42+
setUserPosts(posts);
4943
setUserLevel(level);
50-
await handleGetUserPosts();
5144
}
52-
}, [pageUserId, handleGetUserPosts]);
45+
}, [pageUserId]);
5346

5447
const handleGetLikePosts = useCallback(async () => {
5548
const { likes } = user;
@@ -73,7 +66,7 @@ const UserPage = () => {
7366

7467
return (
7568
<PageWrapper header prev nav info={currentUser.id === pageUserId}>
76-
<UserContainter>
69+
<UserContainer>
7770
<UserData user={user} pageUserId={pageUserId} userLevel={userLevel} />
7871
<Tab onActive={onActive}>
7972
<Tab.Item
@@ -95,7 +88,7 @@ const UserPage = () => {
9588
<PostImageContainer posts={userLikePosts} />
9689
</Tab.Item>
9790
</Tab>
98-
</UserContainter>
91+
</UserContainer>
9992
</PageWrapper>
10093
);
10194
};

src/pages/UserPage/style.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const smallTextStyle = {
3838
color: theme.color.fontNormal,
3939
};
4040

41-
export const UserContainter = styled.div`
41+
export const UserContainer = styled.div`
4242
width: 100%;
4343
position: relative;
4444
background-color: white;

0 commit comments

Comments
 (0)