Skip to content

Commit d9e4130

Browse files
committed
refactor/이미지 개선
1 parent 73367e3 commit d9e4130

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

next.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const nextConfig: NextConfig = {
77
},
88
images: {
99
// 외부 이미지 최적화 완전 비활성화 (Vercel 유료 기능 회피)
10-
unoptimized: true,
10+
// unoptimized: true,
1111
domains: [
1212
'team2-app-s3-bucket.s3.ap-northeast-2.amazonaws.com',
1313
'team2-app-s3-bucket.s3.amazonaws.com',

src/app/(with-layout)/recipe/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,23 @@ import { Suspense } from 'react';
55
import SkeletonRecipe from '@/domains/recipe/skeleton/SkeletonRecipe';
66
import Cocktails from '@/domains/recipe/components/main/Cocktails';
77

8+
89
export const metadata: Metadata = {
910
title: '칵테일레시피',
1011
description: '칵테일 레시피가 궁금하신 분들을 위한 레시피 페이지',
1112
};
1213

14+
1315
function Page() {
16+
1417
return (
1518
<div className="w-full">
1619
<section>
1720
<PageHeader title="Cocktail Recipes" description="다양하고 재밌는 칵테일 레시피" />
1821
</section>
1922
<div className="page-layout max-w-1224 mt-6">
2023
<Suspense fallback={<SkeletonRecipe />}>
21-
<Cocktails />
24+
<Cocktails />
2225
</Suspense>
2326
</div>
2427
</div>

src/domains/mypage/components/pages/my-active/MyComment.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ function MyComment() {
2222
credentials: 'include',
2323
});
2424
const json = await res.json();
25+
2526
setMyComment(json.data.items);
2627
};
2728

29+
2830
useEffect(() => {
2931
fetchComment();
3032
}, []);
3133

3234
return (
3335
<section>
34-
{CommentList.length !== 0 ? (
36+
{myComment.length !== 0 ? (
3537
<CommentList
3638
comments={myComment}
3739
isLoading={isLoading}

src/domains/recipe/components/main/Cocktails.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { useEffect } from 'react';
3+
import { useEffect, useRef } from 'react';
44
import CocktailFilter from './CocktailFilter';
55
import CocktailList from './CocktailList';
66
import CocktailSearchBar from './CocktailSearchBar';
@@ -10,7 +10,6 @@ import CocktailFilterRadios from './CocktailFilterRadios';
1010
import { useCocktailFilter } from '../../hook/useCocktailFilter';
1111
import { useCocktailSearch } from '../../hook/useCocktailSearch';
1212

13-
1413
function Cocktails() {
1514

1615
const {keyword,input,handleSearch} = useCocktailSearch()
@@ -23,18 +22,22 @@ function Cocktails() {
2322
cocktailTypes,
2423
},
2524
20,
26-
sortBy
25+
sortBy,
2726
);
2827

2928
const { ref, inView } = useInView({
3029
threshold: 0.1,
3130
});
3231

32+
const prevInView = useRef(inView);
33+
34+
3335
useEffect(() => {
34-
if (!isSearchMode && inView && hasNextPage) {
36+
if (!isSearchMode && inView && hasNextPage && !prevInView.current) {
3537
fetchNextPage?.();
3638
}
37-
}, [inView, hasNextPage, fetchNextPage]);
39+
prevInView.current = inView
40+
}, [inView, hasNextPage]);
3841

3942

4043

src/domains/shared/components/cocktail-card/CocktailCard.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ function CocktailCard({
4141
className
4242
)}
4343
>
44-
<Image src={src} alt={name} fill className="object-cover" sizes="320px" priority />
44+
<Image
45+
src={src}
46+
alt={name}
47+
fill
48+
className="object-cover"
49+
sizes="320px"
50+
priority
51+
loading='eager'
52+
/>
4553
{keep && (
4654
<div className="flex w-full pl-4 px-3 py-2 items-center justify-between absolute left-0 top-0">
4755
<div>{alcoholTitle && <Label title={alcoholTitle} />}</div>

0 commit comments

Comments
 (0)