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:
getUsersForReaction does not deduplicate users, so a user can appear twice in the list if they appear multiple times in reactionUsers state
- The optimistic update in
handleToggleReaction adds the current user to reactionUsers without checking if they already exist
Steps to reproduce:
- Open any PR
- Go to Conversation tab
- Add a reaction to any comment
- Observe duplicate avatar and count, and React key warning in console
When a user adds a reaction, the avatar and count sometimes appear duplicated. This also triggers a React console error:
Root cause in
apps/web/src/components/shared/reaction-display.tsx:getUsersForReactiondoes not deduplicate users, so a user can appear twice in the list if they appear multiple times inreactionUsersstatehandleToggleReactionadds the current user toreactionUserswithout checking if they already existSteps to reproduce: