Skip to content

Commit

Permalink
Issue 213: Solved missing key warning
Browse files Browse the repository at this point in the history
This commit solves a react warning due to missing key on
list elements. It uses the comment url as key, as there
it no expectation that the same comment will appear twice in
the same replies list.
  • Loading branch information
dellagustin committed Feb 5, 2023
1 parent 2f826a7 commit f021d51
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ui/src/components/Comments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class Comment extends React.PureComponent<ICommentProps> {
</summary>
}
{!this.props.comment.repliesError && this.props.comment.replies && <div>
{this.props.comment.replies.map((reply) => <Comment comment={reply}/>)}
{this.props.comment.replies.map((reply) => <Comment key={reply.url} comment={reply}/>)}
</div>}
{
this.props.comment.repliesError && <div className='contents'>Error loading replies for this comment</div>
Expand Down Expand Up @@ -200,7 +200,7 @@ export default class Comments extends React.PureComponent<IProps, IState> {
<div>
{!this.state.showComments && <button onClick={() => this.onClickShowComments()}>Show comments</button>}
{this.state.showComments && <button onClick={() => this.onClickHideComments()}>Hide comments</button>}
{this.state.showComments && this.state.comments.map((comment) => <Comment comment={comment}/>)}
{this.state.showComments && this.state.comments.map((comment) => <Comment key={comment.url} comment={comment}/>)}
</div>
)
}
Expand Down

0 comments on commit f021d51

Please sign in to comment.