React defaultProps Snippet
Dec 16, 2020
const Rating = ({value, color}) => {
return (
<div className='rating'>
<span>
<i style={{color}}
className={value >= 1 ? "fas fa-star" : value >= 0.5 ? "fas fa-star-half-alt" : "far fa-star"}/>
</span>
</div>
);
};Rating.defaultProps = {
color: "#f8e825"
};
Use color value with props passed by Parent component
Get Jay Han’s stories in your inbox
Join Medium for free to get updates from this writer.
Or use default color value






