Interactive Rating Component using React JS, TypeScript & Tailwind CSS

Solution retrospective
Adding some conditional logic for the element current state, if it is clicked or not.
What challenges did you encounter, and how did you overcome them?{ ratings.map((rating, index) => { // Check if this rating is selected const isSelected = selectedRatingIndex === index // Set the background color based on selection const bgColor = isSelected ? "bg-custom-orange cursor-" : "bg-dark-gray hover:bg-custom-white" // Set the text color based on selection const textColor = isSelected ? "text-black" : "text-light-gray group-hover:text-black" // This will output after conditional logic statement return ( { setSelectedRatingIndex(index) onSelectRating(rating) }} > {rating} ) }) }
At first, I am not familiar how does TypeScript works. But I overcome it by watching several tutorials via Youtube.
Please log in to post a comment
Log in with GitHubCommunity feedback
No feedback yet. Be the first to give feedback on ejaay-dev's solution.
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord