Skip to content

Fix more React warnings of incorrect props.key#3214

Merged
alexr00 merged 3 commits intomicrosoft:mainfrom
blindpirate:fix-more-warnings
Jan 21, 2022
Merged

Fix more React warnings of incorrect props.key#3214
alexr00 merged 3 commits intomicrosoft:mainfrom
blindpirate:fix-more-warnings

Conversation

@blindpirate
Copy link
Contributor

@blindpirate blindpirate commented Dec 30, 2021

There are some warnings in CommentThread because of misuse of
props.key: CommentThread/Diff had no key prop, and
CommentThread incorrectly forwareded key prop to child component.

Xnip2021-12-30_13-18-55


Update: found another missing key prop in MergedEvent:

image

Xnip2021-12-30_14-41-10

There are some warnings in `CommentThread` because of misuse of
`props.key`: `CommentThread`/`Diff` had no `key` prop, and
`CommentThread` incorrectly forwareded `key` prop to child component.
const [revealed, setRevealed] = useState(!comment.isResolved);
const { openDiff } = useContext(PullRequestContext);
return (
<div key={key} className="diff-container">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

special props (ref and key) are used by React, and are thus not forwarded to the component.

@alexr00 alexr00 self-assigned this Jan 14, 2022
@alexr00 alexr00 added this to the January 2022 milestone Jan 14, 2022
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fixes!

@alexr00 alexr00 merged commit 30c22bd into microsoft:main Jan 21, 2022
@blindpirate blindpirate deleted the fix-more-warnings branch January 21, 2022 23:38
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.

2 participants