Grégoire Delattre bcadc48d5a Launch prettier with the --fix option
They've changed their default settings, this changes a lot of stuff in
our code base.
2020-04-01 17:55:34 +02:00

25 lines
475 B
JavaScript

import React from "react";
import PropTypes from "prop-types";
export const Rating = ({ rating, votes }) => {
if (rating === 0) {
return null;
}
return (
<span>
<i className="fa fa-star mr-1"></i>
{Number(rating).toFixed(1)}
{votes !== 0 && <small className="ml-1">({votes} votes)</small>}
</span>
);
};
Rating.propTypes = {
rating: PropTypes.number,
votes: PropTypes.number,
};
Rating.defaultProps = {
rating: 0,
votes: 0,
};