Skip to content

bug: duplicate reaction avatars and keys when toggling reactions #347

@AbhiVarde

Description

@AbhiVarde

When a user adds a reaction, the avatar and count sometimes appear duplicated. This also triggers a React console error:

Encountered two children with the same key <username>. Keys should be unique so that components maintain their identity across updates.

Root cause in apps/web/src/components/shared/reaction-display.tsx:

  1. getUsersForReaction does not deduplicate users, so a user can appear twice in the list if they appear multiple times in reactionUsers state
  2. The optimistic update in handleToggleReaction adds the current user to reactionUsers without checking if they already exist

Steps to reproduce:

  1. Open any PR
  2. Go to Conversation tab
  3. Add a reaction to any comment
  4. Observe duplicate avatar and count, and React key warning in console

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions