Skip to content

Commit

Permalink
無駄なリクエストを削る
Browse files Browse the repository at this point in the history
  • Loading branch information
cp-20 committed Mar 23, 2024
1 parent 179c83f commit b6da86c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import styled from 'styled-components';

import type { GetEpisodeListResponse } from '@wsh-2024/schema/src/api/episodes/GetEpisodeListResponse';

import { Box } from '../../../foundation/components/Box';
import { Flex } from '../../../foundation/components/Flex';
import { Image } from '../../../foundation/components/Image';
Expand All @@ -9,7 +11,6 @@ import { Spacer } from '../../../foundation/components/Spacer';
import { Text } from '../../../foundation/components/Text';
import { useImage } from '../../../foundation/hooks/useImage';
import { Color, Radius, Space, Typography } from '../../../foundation/styles/variables';
import { useEpisode } from '../hooks/useEpisode';

const _Wrapper = styled.li`
width: 100%;
Expand All @@ -29,12 +30,10 @@ const _ImgWrapper = styled.div`

type Props = {
bookId: string;
episodeId: string;
episode: GetEpisodeListResponse[number];
};

export const EpisodeListItem: React.FC<Props> = ({ bookId, episodeId }) => {
const { data: episode } = useEpisode({ params: { episodeId } });

export const EpisodeListItem: React.FC<Props> = ({ bookId, episode }) => {
const imageUrl = useImage({ height: 96, imageId: episode.image.id, width: 96 });

return (
Expand Down
2 changes: 1 addition & 1 deletion workspaces/app/src/pages/BookDetailPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const BookDetailPage: React.FC = () => {
<section aria-label="エピソード一覧">
<Flex align="center" as="ul" direction="column" justify="center">
{episodeList.map((episode) => (
<EpisodeListItem key={episode.id} bookId={bookId} episodeId={episode.id} />
<EpisodeListItem key={episode.id} bookId={bookId} episode={episode} />
))}
{episodeList.length === 0 && (
<>
Expand Down

0 comments on commit b6da86c

Please sign in to comment.