Skip to content

fix(seer-explorer): Memoize repoNames to stabilize useMemo dependencies#111984

Draft
vaind wants to merge 2 commits intomasterfrom
vaind/fix/pr-widget-unstable-memo-deps
Draft

fix(seer-explorer): Memoize repoNames to stabilize useMemo dependencies#111984
vaind wants to merge 2 commits intomasterfrom
vaind/fix/pr-widget-unstable-memo-deps

Conversation

@vaind
Copy link
Copy Markdown
Contributor

@vaind vaind commented Apr 1, 2026

Object.keys(repoStats) in usePRWidgetData was called at function body
level, producing a new array reference on every render. This defeated three
downstream useMemo hooks that listed repoNames in their dependency
arrays, causing them to recompute on every render regardless of whether the
underlying data changed.

Wraps the derivation in its own useMemo keyed on repoStats so the
reference stays stable across rerenders.

Adds a test that verifies memoized values remain referentially identical
across rerenders with unchanged inputs — the test fails without the fix.

Object.keys(repoStats) was called at function body level, producing a
new array reference on every render. This defeated three downstream
useMemo hooks that listed repoNames in their dependency arrays, causing
them to recompute unnecessarily on every render.

Wrap the derivation in its own useMemo keyed on repoStats so the
reference stays stable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant