Skip to content

[Global] Prevent unnecessary re-renders in global top bar #3633

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

finnar-bin
Copy link
Contributor

Prevents unnecessary re-renders in the global top bar to improve overall app performance

@finnar-bin finnar-bin self-assigned this Jul 1, 2025
@finnar-bin finnar-bin added enhancement Improvement to an existing feature ready PR is complete and ready for deployment labels Jul 1, 2025
@finnar-bin finnar-bin linked an issue Jul 1, 2025 that may be closed by this pull request
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR aims to improve overall app performance by preventing unnecessary re-renders in the global top bar. The key changes include:

  • Removing the redundant state parameter from the createTab function, with state now fetched directly within the function.
  • Updating all call sites of createTab to match the new signature.
  • Wrapping TopBarTab and GlobalTopbar components with React.memo to prevent unnecessary re-renders.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/shell/store/ui.ts Modified createTab to remove the explicit state parameter and now retrieve state internally.
src/shell/components/global-tabs/components/Tab.tsx Updated UnpinnedTopBarTab to call the new createTab signature and wrapped TopBarTab using memo.
src/shell/components/GlobalTopbar/GlobalTopbar.tsx Converted GlobalTopbar to a memoized component with displayName assignment.
Comments suppressed due to low confidence (2)

src/shell/store/ui.ts:257

  • Using store.getState() inside createTab decouples the function from the thunk's getState, which may lead to subtle timing issues if the global state and the thunk state differ. Confirm that this design change is intentional and does not introduce stale state problems in asynchronous scenarios.
export function createTab(parsedPath: ParsedPath, queryData?: any) {

src/shell/components/global-tabs/components/Tab.tsx:234

  • The variable queryData is referenced without being defined in UnpinnedTopBarTab. Consider explicitly passing or defining queryData to avoid potential runtime errors.
  const tab = createTab(parsePath(location), queryData);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature ready PR is complete and ready for deployment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global - Unnecessary global top bar re-renders
1 participant