Skip to content

Commit 405d54c

Browse files
committed
chore: 옵셔널 추가
1 parent ba3f36f commit 405d54c

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/components/HomeSwiper.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { Navigation } from "swiper/modules";
99
import Card from "./Card";
1010
import SwiperFooter from "./SwiperFooter";
1111
import { useEffect, useState } from "react";
12-
import { fadeLeftDelayAnimation } from "@theme/animation";
1312
import { GetDaybookResponse } from "@api/response";
1413
import { getRandomDaybooks } from "@api";
1514
import LoadingSpinner from "./LoadingSpinner";
@@ -25,7 +24,7 @@ const HomeSwiper = () => {
2524
})();
2625
}, []);
2726

28-
if (data.length < 1) return <LoadingSpinner />;
27+
if (!data?.length) return <LoadingSpinner />;
2928

3029
return (
3130
<>
@@ -49,12 +48,12 @@ const HomeSwiper = () => {
4948
className="mySwiper"
5049
onSlideChange={(swiper) => setCurrentIndex(swiper.activeIndex)}
5150
>
52-
{data.map((x, i) => (
51+
{data?.map((x, i) => (
5352
<CardSlide key={i}>
5453
<Card isHome isCurrent={i === currentIndex} daybook={x} />
5554
</CardSlide>
5655
))}
57-
<SwiperFooter maxIndex={data.length} currentIndex={currentIndex} />
56+
<SwiperFooter maxIndex={data?.length} currentIndex={currentIndex} />
5857
</Swiper>
5958
</>
6059
);
@@ -67,5 +66,4 @@ const CardSlide = styled(SwiperSlide)`
6766
display: flex;
6867
justify-content: center;
6968
align-items: center;
70-
/* ${fadeLeftDelayAnimation} */
7169
`;

src/components/MyWritingSwiper.tsx

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import { Swiper, SwiperSlide } from 'swiper/react';
2-
import { css } from '@emotion/react';
3-
import styled from '@emotion/styled';
4-
import 'swiper/css';
5-
import 'swiper/css/effect-coverflow';
6-
import 'swiper/css/pagination';
1+
import { Swiper, SwiperSlide } from "swiper/react";
2+
import { css } from "@emotion/react";
3+
import styled from "@emotion/styled";
4+
import "swiper/css";
5+
import "swiper/css/effect-coverflow";
6+
import "swiper/css/pagination";
77

8-
import { Navigation } from 'swiper/modules';
9-
import Card from './Card';
10-
import SwiperFooter from './SwiperFooter';
11-
import { useEffect, useState } from 'react';
12-
import { getDaybookList } from '@api';
13-
import { GetDaybookResponse } from '@api/response';
14-
import LoadingSpinner from './LoadingSpinner';
8+
import { Navigation } from "swiper/modules";
9+
import Card from "./Card";
10+
import SwiperFooter from "./SwiperFooter";
11+
import { useEffect, useState } from "react";
12+
import { getDaybookList } from "@api";
13+
import { GetDaybookResponse } from "@api/response";
14+
import LoadingSpinner from "./LoadingSpinner";
1515

1616
const MyWritingSwiper = () => {
1717
const [data, setData] = useState<GetDaybookResponse[]>([]);
@@ -24,7 +24,7 @@ const MyWritingSwiper = () => {
2424
})();
2525
}, []);
2626

27-
if (data.length < 1) return <LoadingSpinner />;
27+
if (!data?.length) return <LoadingSpinner />;
2828

2929
return (
3030
<>
@@ -53,7 +53,7 @@ const MyWritingSwiper = () => {
5353
<Card isCurrent={currentIndex === i} daybook={daybook} />
5454
</CardSlide>
5555
))}
56-
<SwiperFooter maxIndex={data.length} currentIndex={currentIndex} />
56+
<SwiperFooter maxIndex={data?.length} currentIndex={currentIndex} />
5757
</Swiper>
5858
</>
5959
);

0 commit comments

Comments
 (0)