Problem
Build a reusable star rating widget used in product reviews.
Requirements
- Display 5 stars; click to set rating (1–5).
- Hover preview before click.
- Keyboard: arrow keys adjust rating, Enter confirms.
- Emit
onChange(rating)to parent. - (Bonus) read-only mode, half-star increments, ARIA (
role="slider").
Hints / Approach
- Track
rating(committed) andhover(preview) separately. - Render stars as buttons with
aria-label. - Use
onMouseEnter/onMouseLeaveon container for hover state.