React defaultProps Snippet

Jay Han
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

Or use default color value

--

--