Skip to content

Commit

Permalink
chore: 옵셔널 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoung-jnn committed Apr 6, 2024
1 parent ba3f36f commit 405d54c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
8 changes: 3 additions & 5 deletions src/components/HomeSwiper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Navigation } from "swiper/modules";
import Card from "./Card";
import SwiperFooter from "./SwiperFooter";
import { useEffect, useState } from "react";
import { fadeLeftDelayAnimation } from "@theme/animation";
import { GetDaybookResponse } from "@api/response";
import { getRandomDaybooks } from "@api";
import LoadingSpinner from "./LoadingSpinner";
Expand All @@ -25,7 +24,7 @@ const HomeSwiper = () => {
})();
}, []);

if (data.length < 1) return <LoadingSpinner />;
if (!data?.length) return <LoadingSpinner />;

return (
<>
Expand All @@ -49,12 +48,12 @@ const HomeSwiper = () => {
className="mySwiper"
onSlideChange={(swiper) => setCurrentIndex(swiper.activeIndex)}
>
{data.map((x, i) => (
{data?.map((x, i) => (
<CardSlide key={i}>
<Card isHome isCurrent={i === currentIndex} daybook={x} />
</CardSlide>
))}
<SwiperFooter maxIndex={data.length} currentIndex={currentIndex} />
<SwiperFooter maxIndex={data?.length} currentIndex={currentIndex} />
</Swiper>
</>
);
Expand All @@ -67,5 +66,4 @@ const CardSlide = styled(SwiperSlide)`
display: flex;
justify-content: center;
align-items: center;
/* ${fadeLeftDelayAnimation} */
`;
30 changes: 15 additions & 15 deletions src/components/MyWritingSwiper.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Swiper, SwiperSlide } from 'swiper/react';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import 'swiper/css';
import 'swiper/css/effect-coverflow';
import 'swiper/css/pagination';
import { Swiper, SwiperSlide } from "swiper/react";
import { css } from "@emotion/react";
import styled from "@emotion/styled";
import "swiper/css";
import "swiper/css/effect-coverflow";
import "swiper/css/pagination";

import { Navigation } from 'swiper/modules';
import Card from './Card';
import SwiperFooter from './SwiperFooter';
import { useEffect, useState } from 'react';
import { getDaybookList } from '@api';
import { GetDaybookResponse } from '@api/response';
import LoadingSpinner from './LoadingSpinner';
import { Navigation } from "swiper/modules";
import Card from "./Card";
import SwiperFooter from "./SwiperFooter";
import { useEffect, useState } from "react";
import { getDaybookList } from "@api";
import { GetDaybookResponse } from "@api/response";
import LoadingSpinner from "./LoadingSpinner";

const MyWritingSwiper = () => {
const [data, setData] = useState<GetDaybookResponse[]>([]);
Expand All @@ -24,7 +24,7 @@ const MyWritingSwiper = () => {
})();
}, []);

if (data.length < 1) return <LoadingSpinner />;
if (!data?.length) return <LoadingSpinner />;

return (
<>
Expand Down Expand Up @@ -53,7 +53,7 @@ const MyWritingSwiper = () => {
<Card isCurrent={currentIndex === i} daybook={daybook} />
</CardSlide>
))}
<SwiperFooter maxIndex={data.length} currentIndex={currentIndex} />
<SwiperFooter maxIndex={data?.length} currentIndex={currentIndex} />
</Swiper>
</>
);
Expand Down

0 comments on commit 405d54c

Please sign in to comment.