Skip to content

Commit

Permalink
✨ 메인페이지 로딩 스피너 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
te-ing committed Aug 21, 2022
1 parent 0293d06 commit 1aa4fc5
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import postsApi from 'apis/posts.api';
import { MainPostType } from 'types/post';
import { useQuery } from 'react-query';
import { isLoggedIn } from 'utils/isLoggedIn';
import LoadingSpinner from 'components/common/LoadingSpinner';

const PostCards = () => {
const getPosts = async () => {
Expand All @@ -34,14 +35,16 @@ const PostCards = () => {
</MainHeader>
<FlexCenter>
<MainContent>
{isLoading || !data.userPost?.concat(data.teamPost).length
? 'Loading..'
: data.userPost
.concat(data.teamPost)
.sort(() => Math.random() - 0.5)
.map((post) => {
return <MainCard post={post} key={post.team ? `team${post.id}` : `user${post.id}`} />;
})}
{isLoading || !data.userPost?.concat(data.teamPost).length ? (
<LoadingSpinner />
) : (
data.userPost
.concat(data.teamPost)
.sort(() => Math.random() - 0.5)
.map((post) => {
return <MainCard post={post} key={post.team ? `team${post.id}` : `user${post.id}`} />;
})
)}
</MainContent>
</FlexCenter>
</Layout>
Expand Down

0 comments on commit 1aa4fc5

Please sign in to comment.