-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix duplicate collaborator entries in collaboration panel #422
Conversation
The warningWarning: Each child in a list should have a unique "key" prop. Check the render method of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @nzinfo.
How about making collaborators
a Map
, instead of having the keys in collaborators_keys
and the values in collaborators
?
@davidbrochart Thank you for the review. I've changed collaborators into a map. |
return ( | ||
<Collaborator | ||
key={uniqueKey} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it is needed for React to know which entry is which.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and It's the key that can avoid the warning "Warning: Each child in a list should have a unique "key" prop."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nzinfo.
Problem
When the same user connects from multiple browsers, the collaborator panel may show duplicate entries even when they are viewing the same file. This causes unnecessary clutter and React key warnings.
Solution
_onAwarenessChanged
using a Set to track unique combinations of username and current fileChanges
collaborators_keys
Set to track unique collaborator entriesTesting