Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 4, 2025

The inline empty array fallback performanceMap[validator.address] || [] creates a new array instance on every render when the key is undefined, causing unnecessary re-renders despite React.memo on the Item component.

Changes

  • Define EMPTY_ERA_POINTS constant outside component for stable reference
  • Replace inline || [] with ?? EMPTY_ERA_POINTS
// Before: new array instance on each render
eraPoints={performanceMap[validator.address] || []}

// After: stable reference
const EMPTY_ERA_POINTS: ValidatorEraPoints[] = []
// ...
eraPoints={performanceMap[validator.address] ?? EMPTY_ERA_POINTS}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Refactor address feedback on React.memo changes Fix empty array fallback defeating React.memo optimization Dec 4, 2025
Copilot AI requested a review from rossbulat December 4, 2025 07:30
@rossbulat rossbulat marked this pull request as ready for review December 4, 2025 07:42
@rossbulat rossbulat merged commit 5e3d7ec into JK-Memo Dec 4, 2025
1 check passed
@rossbulat rossbulat deleted the copilot/sub-pr-3128 branch December 4, 2025 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants