perf(frontend): blank Suspense → Spin loader, matchMedia resize hook, virtual table scrolling - #6187
Open
PathGao wants to merge 1 commit into
Open
Conversation
… matchMedia hook, add virtual table scrolling
- routes.tsx, LazyMount.tsx: replace Suspense fallback={null} with Spin
loader so page transitions and lazy modals never show blank content
- useMediaQuery.ts: switch from resize event to matchMedia change event,
eliminating state updates on every pixel drag; export MOBILE_BREAKPOINT_PX
- SubPage.tsx: drop duplicate inline isMobile logic (7 lines), use shared
useMediaQuery(576) (2 lines)
- ClientsPage, InboundList, HostList, NodeList: add virtual + scroll.y to
Table for viewport-only DOM rendering of large datasets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
useMediaQueryswitched fromresizetomatchMediauseMediaQuery.ts— the hook listened towindow.resizewhich 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 nativewindow.matchMedia("(max-width: Npx)").changeevent which fires only when the query actually flips. Also exportsMOBILE_BREAKPOINT_PX.SubPage.tsx— dropped a duplicate inlineisMobileimplementation (its ownuseState+resizelistener at a hardcoded 576px breakpoint) in favor of the shareduseMediaQuery(576)hook. Net −6 lines.Efficient: virtual scrolling on 4 large tables
ClientsPage.tsx,InboundList.tsx,HostList.tsx,NodeList.tsx— added antd Tablevirtualprop withscroll.y(viewport-relative calc). On large datasets, only the visible rows are rendered in the DOM. Tables withpagination={false}(HostList, NodeList) benefit most; paginated tables benefit at larger page sizes.calc(100vh - 380px)calc(100vh - 320px)calc(100vh - 280px)calc(100vh - 320px)Verification
Suspense/Spin/virtualare already used elsewhere in this codebase