From f920b2001d4da22b0872580cecdbd86a08380f57 Mon Sep 17 00:00:00 2001 From: xiaotianxt Date: Thu, 6 Apr 2023 02:41:27 +0800 Subject: [PATCH] performance: introduce lazy-loading for ChatList Reduce the first load JS bundle size using next/dynamic. --- app/components/home.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/components/home.tsx b/app/components/home.tsx index 66f86348..9e57cb87 100644 --- a/app/components/home.tsx +++ b/app/components/home.tsx @@ -19,7 +19,6 @@ import CloseIcon from "../icons/close.svg"; import { useChatStore } from "../store"; import { isMobileScreen } from "../utils"; import Locale from "../locales"; -import { ChatList } from "./chat-list"; import { Chat } from "./chat"; import dynamic from "next/dynamic"; @@ -39,6 +38,10 @@ const Settings = dynamic(async () => (await import("./settings")).Settings, { loading: () => , }); +const ChatList = dynamic(async () => (await import("./chat-list")).ChatList, { + loading: () => , +}); + function useSwitchTheme() { const config = useChatStore((state) => state.config);