Skip to content

Instantly share code, notes, and snippets.

@40thieves
Created February 15, 2019 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 40thieves/8c5354dd6310499128a0765de3894c13 to your computer and use it in GitHub Desktop.
Save 40thieves/8c5354dd6310499128a0765de3894c13 to your computer and use it in GitHub Desktop.
import React, { Component } from "react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import "./ranking.css";
class Ranking extends Component {
//
render() {
console.log(this.props.articles);
return (
<div className="rank_border">
<h1>Please Rank Your articles by clicking the Heart Icon</h1>
// I add an index here
{this.props.articles.map((article, index) => {
return (
<div>
<div className="rank_title">
<h1 key={index}>{article.title}</h1>
<div>
<button onClick={() => this.props.addLikes(index)}>
<FontAwesomeIcon icon="heart" className="heart" />
</button>
<p>{this.props.likes}</p>
<button onClick={this.props.subtractLikes}>
<FontAwesomeIcon
icon="heart-broken"
className="heartbroken"
/>
</button>
</div>
</div>
</div>
);
})}
</div>
);
}
}
export default Ranking;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment