Skip to content

Instantly share code, notes, and snippets.

@iwilsonq
Last active April 30, 2018 01:24
Show Gist options
  • Save iwilsonq/1602f05356afa8499721799c760bf0fe to your computer and use it in GitHub Desktop.
Save iwilsonq/1602f05356afa8499721799c760bf0fe to your computer and use it in GitHub Desktop.
A Go script generated gist.
const Comment = props => {
const isLiked = props.likes.includes(props.currentUser.id)
const onClick = isLiked
? () => props.onDislike(props.id)
: () => props.onLike(props.id)
return (
<div className="Comment">
<h4>{props.author}</h4>
<p>{props.text}</p>
<button data-testid={props.id} onClick={onClick}>
{isLiked ? 'Unlike' : 'Like'}
</button>
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment