Repository navigation
perf(citations): make Domains/URLs tab switching instant (keepMounted + memo) - #325
Merged
Merged
Conversation
… + memo)
Tab switching does no async work — both tables are fed from the same
in-memory getCitationsOverview() result. The lag was unmount/re-mount:
Base-UI Tabs.Panel unmounts the inactive panel by default, so each switch
rebuilt the (uncapped) table from scratch.
- Pass keepMounted to the Domains/URLs TabsContent so both mount once and
switching is a pure CSS visibility toggle.
- Wrap DomainsTable / UrlsTable in React.memo so an unrelated parent
re-render (e.g. filter state) doesn't re-render the whole table when its
rows reference is unchanged.
No skeleton (data is already loaded). tabs.tsx unchanged — keepMounted
reaches Tabs.Panel via {...props}.
5 tasks
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
Switching the Domains ↔ URLs tabs on the Citations page felt sluggish for brands with many cited domains/URLs. It's not a data fetch — both tables come from the same in-memory
getCitationsOverview()result. The cost was unmount/re-mount: Base-UI'sTabs.Panelunmounts the inactive panel by default, so each switch destroyed one (uncapped) table and rebuilt the other from scratch.Fix (
web/src/app/[locale]/(dashboard)/dashboard/citations/page.tsx):keepMountedon the Domains/URLsTabsContent→ both panels mount once and switching is a pure CSS visibility toggle (instant). Since the data is already fetched, this is a one-time render cost, not per-switch.React.memoaroundDomainsTable/UrlsTable→ an unrelated parent re-render (e.g. filter state) doesn't re-render the whole table while itsrowsreference is unchanged.No skeleton — the data is already loaded and the switch does no async work, so a skeleton would only flash an empty placeholder and make it feel worse.
web/src/components/ui/tabs.tsxneeded no change:keepMountedalready reachesTabs.Panelvia{...props}(confirmed by typecheck accepting it onTabsContent).Related issue
Closes #299
Type of change
feat— New feature (performance)How to test
/dashboard/citationsfor a brand with many cited URLs.Notes
Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdyarn lintpasses (run fromweb/)yarn typecheckpasses (run fromweb/)yarn format:checkpasses (run fromweb/)