Skip to content

fix: memo comparison functions return false instead of true#1329

Closed
alessandroliva wants to merge 1 commit intovercel:main-2026-03-20from
alessandroliva:main
Closed

fix: memo comparison functions return false instead of true#1329
alessandroliva wants to merge 1 commit intovercel:main-2026-03-20from
alessandroliva:main

Conversation

@alessandroliva
Copy link
Copy Markdown

@alessandroliva alessandroliva commented Nov 26, 2025

In this PR I propose a fix for React.memo comparison functions in Messages and PreviewMessage that always returne false, effectively disabling memoization.

Problem

Both components define a custom comparison function for React.memo, but they end with an unconditional return false.
Because the final line is always false, these components re-render on every parent update, regardless of whether the relevant props actually changed.

Testing

Verified the app still updates when:

  • New messages are added.
  • Streaming status changes (e.g. streamingready).
  • Votes change.
    Confirmed that, when props are unchanged, the components are now eligible to be skipped by React.memo, reducing unnecessary re-renders in longer chats.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Nov 26, 2025

@alessandroliva is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@MrAllgoodWilson
Copy link
Copy Markdown

I approve

@alessandroliva
Copy link
Copy Markdown
Author

@MrAllgoodWilson please stop spamming

@dancer dancer deleted the branch vercel:main-2026-03-20 March 20, 2026 11:23
@dancer dancer closed this Mar 20, 2026
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.

3 participants