Skip to content

⚡ Bolt: Optimize PlayerList rendering#22

Open
WeixuanZ wants to merge 1 commit intomasterfrom
bolt-performance-playerlist-memo-9486316830641509692
Open

⚡ Bolt: Optimize PlayerList rendering#22
WeixuanZ wants to merge 1 commit intomasterfrom
bolt-performance-playerlist-memo-9486316830641509692

Conversation

@WeixuanZ
Copy link
Owner

@WeixuanZ WeixuanZ commented Feb 4, 2026

💡 What:

  • Wrapped PlayerCard component in React.memo.
  • Implemented arePlayerCardPropsEqual to compare relevant player fields (id, nickname, role, status, etc.) instead of relying on object reference equality.
  • Explicitly excluded the onKick prop from comparison as it is behaviorally stable but referentially unstable, preventing false negatives in equality checks.

🎯 Why:

  • The players list is derived from a global GameState object which is recreated on every update (e.g. from WebSocket).
  • This caused every PlayerCard to re-render whenever any part of the game state changed, even if the player's data was identical.
  • In a game with 10+ players and frequent updates (timer, voting), this caused significant unnecessary rendering work.

📊 Impact:

  • drastically reduces re-renders of PlayerCard components.
  • Improves rendering performance during active game phases.

🔬 Measurement:

  • Verified via logic that PlayerCard props are now compared by value for relevant fields.
  • Verified build and lint passes.

PR created automatically by Jules for task 9486316830641509692 started by @WeixuanZ

Refactors `PlayerList` to use `React.memo` for the `PlayerCard` component.
Includes a custom comparison function `arePlayerCardPropsEqual` to prevent
unnecessary re-renders when the global game state updates but individual
player data remains visually identical.

This improves performance in high-frequency update scenarios (e.g. timers,
voting) by avoiding re-rendering the entire player grid.

Co-authored-by: WeixuanZ <39925558+WeixuanZ@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant