Project 3 from 25 projects (star rating)
1 Create a component called "star-rating".
2 Installed react icons package.
3 Created an array with ...Array .map which returns an icon with key, onClick, inMouseMove, onMouseLeave, size.
4 Created two useStates hover and rating.
5 On icon, onClick handles handleClick, onMouseMove handles handleMouseEnter and onMouseLeave handles handleMouseLeave with props of index.
6 handleClick with gecurrrentIndex setsRating to getCurrentIndex.
7 handleMouseEnter setsHover to getCurrentIndex.
8 handleMouseLeave setsHover to default rating.
9 Set the className in such a way that if index is <=(hover OR rating) then the className is active else it is inactive.
10 Set the color is style.css.
Note: ...Array means an array which updates along with previous arrays.
Comments
Post a Comment