Skip to content

Commit a69148a

Browse files
authored
[IMPROVE] 전체적으로 dynamic, lazy 적용 (#59)
* feat: dynamic + suspense 구조에서 dynamic 구조로 변경 * refactor: suspense가 필요없는 dynamic은 lazy로 변경
1 parent c05e6ff commit a69148a

3 files changed

Lines changed: 8 additions & 24 deletions

File tree

apps/web/src/app/(with-side-bar)/topic/[id]/layout.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
"use client";
1+
import { lazy } from "react";
22

3-
import dynamic from "next/dynamic";
4-
5-
const TopicStickerDetailModal = dynamic(
6-
() => import("@/components/(with-side-bar)/topic/sticker/topic-sticker-detail-modal"),
7-
{
8-
ssr: false,
9-
}
3+
const TopicStickerDetailModal = lazy(
4+
() => import("@/components/(with-side-bar)/topic/sticker/topic-sticker-detail-modal")
105
);
116

127
interface TopicBoardLayoutProps {

apps/web/src/components/(with-side-bar)/layout/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"use client";
22

3-
import { Suspense } from "react";
43
import dynamic from "next/dynamic";
54
import Link from "next/link";
65
import { usePathname } from "next/navigation";
@@ -95,9 +94,7 @@ export default function Sidebar() {
9594
<div className="text-muted-foreground mb-4 text-sm font-semibold uppercase tracking-wider">
9695
나의 토픽
9796
</div>
98-
<Suspense fallback={<Spinner className="mx-auto" />}>
99-
<RecentTopicList />
100-
</Suspense>
97+
<RecentTopicList />
10198
</div>
10299
</aside>
103100

apps/web/src/components/(with-side-bar)/topic/add-content.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { Suspense, useRef, useState } from "react";
3+
import { useRef, useState } from "react";
44
import dynamic from "next/dynamic";
55
import Link from "next/link";
66

@@ -20,15 +20,15 @@ const AddContentList = dynamic(() => import("./add-content-list"), {
2020
),
2121
});
2222

23-
interface AddContentListProps {
23+
interface AddContentProps {
2424
type: ContentTypeOptions;
2525
id: string;
2626
}
2727

2828
const MIN_WIDTH = 300;
2929
const MAX_WIDTH = 600;
3030

31-
export default function AddContent({ type, id }: AddContentListProps) {
31+
export default function AddContent({ type, id }: AddContentProps) {
3232
const [contentPanelWidth, setContentPanelWidth] = useState(300); // Content Panel 기본 너비
3333
const [searchQuery, setSearchQuery] = useState("");
3434

@@ -90,15 +90,7 @@ export default function AddContent({ type, id }: AddContentListProps) {
9090
<Link href={`/topic/${id}?type=${CONTENT_TYPE_OPTIONS.YOUTUBE}`}>유튜브</Link>
9191
</Button>
9292
</div>
93-
<Suspense
94-
fallback={
95-
<div className="flex justify-center py-2">
96-
<Spinner />
97-
</div>
98-
}
99-
>
100-
<AddContentList query={debouncedSearchQuery} id={id} type={type} />
101-
</Suspense>
93+
<AddContentList query={debouncedSearchQuery} id={id} type={type} />
10294
</div>
10395
<ResizeBar onMouseMove={onMouseMove} />
10496
</>

0 commit comments

Comments
 (0)