Skip to content

Commit 552cf76

Browse files
committed
fix: error 및 not found 페이지의 애니메이션 요소를 비동기적으로 불러오도록 변경
1 parent 62a7295 commit 552cf76

File tree

7 files changed

+236
-12
lines changed

7 files changed

+236
-12
lines changed

next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @type {import('next').NextConfig} */
12
const nextConfig = {
23
images: {
34
unoptimized: true,

package-lock.json

Lines changed: 186 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"scripts": {
66
"dev": "next dev",
77
"build": "next build",
8+
"analyze": "npx @next/bundle-analyzer .next/static/chunks/",
89
"start": "next start",
910
"lint": "next lint",
1011
"prepare": "husky",
@@ -74,6 +75,7 @@
7475
},
7576
"devDependencies": {
7677
"@eslint/eslintrc": "^3",
78+
"@next/bundle-analyzer": "^15.5.3",
7779
"@storybook/addon-essentials": "7.6.20",
7880
"@storybook/addon-interactions": "7.6.20",
7981
"@storybook/addon-links": "7.6.20",

src/app/activities/[activityId]/ActivityClientPage.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export default function ActivityClient({ activityId, blurImage }: ActivityClient
3232
const { user } = useUserStore();
3333
const queryClient = useQueryClient();
3434

35-
// Intersection Observer for performance optimization
3635
const [mapRef, isMapVisible] = useIntersectionObserver({
3736
rootMargin: '100px',
3837
triggerOnce: true,
@@ -58,7 +57,7 @@ export default function ActivityClient({ activityId, blurImage }: ActivityClient
5857
gcTime: 60 * 60 * 1000, // 1시간 메모리 보관
5958
});
6059

61-
// 2. 동적 데이터 (가격, 스케줄, 평점) - 짧은 캐시, 캐시 재사용 최적화
60+
// 2. 동적 데이터 (가격, 스케줄, 평점) - 짧은 캐시, 재사용 최적화
6261
const { data: dynamicInfo } = useSuspenseQuery({
6362
queryKey: [...activityQueryKeys.detail(activityId), 'dynamic'],
6463
queryFn: (): Promise<ActivityDetail> => {
@@ -72,7 +71,7 @@ export default function ActivityClient({ activityId, blurImage }: ActivityClient
7271
'static',
7372
]);
7473

75-
// static 캐시가 fresh하면(2분 이내) 재사용
74+
// static 캐시가 fresh하면 재사용
7675
if (
7776
cachedData &&
7877
cachedState?.dataUpdatedAt &&
@@ -148,7 +147,6 @@ export default function ActivityClient({ activityId, blurImage }: ActivityClient
148147
</NaverMap>
149148
) : (
150149
<div className='h-64 bg-gray-100 rounded-lg animate-pulse flex items-center justify-center'>
151-
{/* MapPinned 아이콘 하나가 중앙에서 콩콩 뛰는 애니메이션 */}
152150
<motion.div
153151
animate={{
154152
y: [0, -20, 0],

src/app/activities/[activityId]/not-found.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
'use client';
22

3-
import Lottie from 'lottie-react';
4-
import loadingLottie from '@/assets/lottie/404 Error - Doodle animation.json';
53
import Link from 'next/link';
4+
import { lazy, Suspense, useState, useEffect } from 'react';
5+
6+
const Lottie = lazy(() => import('lottie-react'));
67

78
export default function ActivityNotFound() {
9+
const [animationData, setAnimationData] = useState<object | null>(null);
10+
11+
useEffect(() => {
12+
// 404 애니메이션 동적 로드 (305KB)
13+
import('@/assets/lottie/404 Error - Doodle animation.json')
14+
.then((module) => setAnimationData(module.default))
15+
.catch(() => setAnimationData(null));
16+
}, []);
17+
818
return (
919
<div className='flex flex-col items-center min-h-screen text-title overflow-hidden'>
1020
<div className='w-100 h-100'>
11-
<Lottie animationData={loadingLottie} />
21+
{animationData ? (
22+
<Suspense
23+
fallback={<div className='animate-pulse bg-gray-100 rounded-2xl w-100 h-100'></div>}
24+
>
25+
<Lottie animationData={animationData} />
26+
</Suspense>
27+
) : (
28+
<div className='animate-pulse bg-gray-100 rounded-2xl w-100 h-100'></div>
29+
)}
1230
</div>
1331

1432
<div className='flex mt-8 text-24-regular text-subtitle'>체험을 찾을 수 없습니다.</div>

0 commit comments

Comments
 (0)