[PR #6187] [MERGED] perf(frontend): blank Suspense → Spin loader, matchMedia resize hook, virtual table scrolling #6149

Closed
opened 2026-11-02 04:06:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6187
Author: @PathGao
Created: 8/8/2026
Status: ✅ Merged
Merged: 8/15/2026
Merged by: @MHSanaei

Base: main ← Head: perf/frontend-loading-virtual-scroll


📝 Commits (3)

  • 784c172 perf(frontend): replace blank Suspense fallbacks with Spin, switch to matchMedia hook, add virtual table scrolling
  • 47eee26 Merge branch 'main' into perf/frontend-loading-virtual-scroll
  • 3a733f2 Merge branch 'main' into perf/frontend-loading-virtual-scroll

📊 Changes

8 files changed (+42 additions, -20 deletions)

View changed files

📝 frontend/src/components/utility/LazyMount.tsx (+2 -1)
📝 frontend/src/hooks/useMediaQuery.ts (+18 -6)
📝 frontend/src/pages/clients/ClientsPage.tsx (+2 -1)
📝 frontend/src/pages/hosts/HostList.tsx (+2 -1)
📝 frontend/src/pages/inbounds/list/InboundList.tsx (+2 -1)
📝 frontend/src/pages/nodes/NodeList.tsx (+2 -1)
📝 frontend/src/pages/sub/SubPage.tsx (+2 -8)
📝 frontend/src/routes.tsx (+12 -1)

📄 Description

Summary

8 files, +42/−20 — all low-cost optimizations in the frontend layer.

Visual: blank Suspense fallback → centered <Spin>

routes.tsx + LazyMount.tsx — every route change and lazy modal used to render nothing (fallback={null}) while the code chunk loaded, showing a blank screen. Now shows a centered antd Spin loader, matching the established loading pattern already used in the codebase.

Efficient: useMediaQuery switched from resize to matchMedia

useMediaQuery.ts — the hook listened to window.resize which fires on every pixel of window drag, triggering state updates and React re-renders in every component tree that calls it (most pages). Now uses the native window.matchMedia("(max-width: Npx)").change event which fires only when the query actually flips. Also exports MOBILE_BREAKPOINT_PX.

SubPage.tsx — dropped a duplicate inline isMobile implementation (its own useState + resize listener at a hardcoded 576px breakpoint) in favor of the shared useMediaQuery(576) hook. Net −6 lines.

Efficient: virtual scrolling on 4 large tables

ClientsPage.tsx, InboundList.tsx, HostList.tsx, NodeList.tsx — added antd Table virtual prop with scroll.y (viewport-relative calc). On large datasets, only the visible rows are rendered in the DOM. Tables with pagination={false} (HostList, NodeList) benefit most; paginated tables benefit at larger page sizes.

Table scroll.y
ClientsPage calc(100vh - 380px)
InboundList calc(100vh - 320px)
HostList calc(100vh - 280px)
NodeList calc(100vh - 320px)

Verification

  • All changes are TypeScript-level only (no backend changes)
  • Suspense/Spin/virtual are already used elsewhere in this codebase
  • No new dependencies introduced

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6187 **Author:** [@PathGao](https://github.com/PathGao) **Created:** 8/8/2026 **Status:** ✅ Merged **Merged:** 8/15/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `perf/frontend-loading-virtual-scroll` --- ### 📝 Commits (3) - [`784c172`](https://github.com/MHSanaei/3x-ui/commit/784c172cf5a1fcfb4f7d4b293f74e2c34f62e4d7) perf(frontend): replace blank Suspense fallbacks with Spin, switch to matchMedia hook, add virtual table scrolling - [`47eee26`](https://github.com/MHSanaei/3x-ui/commit/47eee2692f67d4e6e65c69cf6787d8b2e7e1dc13) Merge branch 'main' into perf/frontend-loading-virtual-scroll - [`3a733f2`](https://github.com/MHSanaei/3x-ui/commit/3a733f2fea8feba836c182f7d9ccf56d7af0e710) Merge branch 'main' into perf/frontend-loading-virtual-scroll ### 📊 Changes **8 files changed** (+42 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/components/utility/LazyMount.tsx` (+2 -1) 📝 `frontend/src/hooks/useMediaQuery.ts` (+18 -6) 📝 `frontend/src/pages/clients/ClientsPage.tsx` (+2 -1) 📝 `frontend/src/pages/hosts/HostList.tsx` (+2 -1) 📝 `frontend/src/pages/inbounds/list/InboundList.tsx` (+2 -1) 📝 `frontend/src/pages/nodes/NodeList.tsx` (+2 -1) 📝 `frontend/src/pages/sub/SubPage.tsx` (+2 -8) 📝 `frontend/src/routes.tsx` (+12 -1) </details> ### 📄 Description ## Summary 8 files, +42/−20 — all low-cost optimizations in the frontend layer. ### Visual: blank Suspense fallback → centered `<Spin>` **`routes.tsx` + `LazyMount.tsx`** — every route change and lazy modal used to render nothing (`fallback={null}`) while the code chunk loaded, showing a blank screen. Now shows a centered antd Spin loader, matching the established loading pattern already used in the codebase. ### Efficient: `useMediaQuery` switched from `resize` to `matchMedia` **`useMediaQuery.ts`** — the hook listened to `window.resize` which fires on every pixel of window drag, triggering state updates and React re-renders in every component tree that calls it (most pages). Now uses the native `window.matchMedia("(max-width: Npx)").change` event which fires only when the query actually flips. Also exports `MOBILE_BREAKPOINT_PX`. **`SubPage.tsx`** — dropped a duplicate inline `isMobile` implementation (its own `useState` + `resize` listener at a hardcoded 576px breakpoint) in favor of the shared `useMediaQuery(576)` hook. Net −6 lines. ### Efficient: virtual scrolling on 4 large tables **`ClientsPage.tsx`, `InboundList.tsx`, `HostList.tsx`, `NodeList.tsx`** — added antd Table `virtual` prop with `scroll.y` (viewport-relative calc). On large datasets, only the visible rows are rendered in the DOM. Tables with `pagination={false}` (HostList, NodeList) benefit most; paginated tables benefit at larger page sizes. | Table | scroll.y | |-------------|---------------------------| | ClientsPage | `calc(100vh - 380px)` | | InboundList | `calc(100vh - 320px)` | | HostList | `calc(100vh - 280px)` | | NodeList | `calc(100vh - 320px)` | ## Verification - All changes are TypeScript-level only (no backend changes) - `Suspense`/`Spin`/`virtual` are already used elsewhere in this codebase - No new dependencies introduced --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:06:42 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6149
No description provided.