Skip to content

perf: stop Inbox rows re-rendering when a right-hand panel opens #106767

Open

Description

@mountiny

Problem

LHNTooltipContextProvider puts useIsFocused() and a root navigation flag in the same context value that every Inbox row reads. When an RHP such as Create expense opens, the Inbox loses focus, the context value changes, and every visible row re-renders with its whole subtree, even though the RHP hides the Inbox. On native the Inbox tab stays mounted under every RHP, so this cost grows with the number of reports.

Solution

Split the context in three. LHNTooltipContext keeps the onboarding data the rows show. LHNTooltipActionsContext holds hideConciergeTooltip and getIsScreenFocused, backed by refs so its value never changes. LHNTooltipVisibilityContext holds the focus, navigation and fullscreen flags, and only the row that renders the Concierge tooltip reads it. The provider also calls useLHNRowProductTrainingTooltip once instead of once per row. On a heavy account in an iOS DEV build, the median time to open Create expense drops from 318 ms to 240.5 ms, and p90 drops from 938 ms to 397 ms.

PR

#106735

Issue OwnerCurrent Issue Owner: @BartekObudzinski

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions