react-rating
react-rating copied to clipboard
Selection requires double click if onClick method provided
Hello,
If I provide an onClick method to get the selected rating, it requires another click to the same value although it gets the rating in the first click. You can check it from this link: https://stackblitz.com/edit/react-buosnw
In summary, if you click a rating, it is not turning to a full symbol. If you click the same rating again, then it turns to a full symbol. This is not happening if there is no onClick method.
Thanks
For the people who are looking for a solution to this problem, my workaround is setting the initialRating in onClick.
I have the same issue, would you share some sample code because in onClick we can't access to event
@amastaneh Here is the code:
const [selectedRating, setSelectedRating] = useState();
const onRatingSelected = selectedValue => {
setSelectedRating(selectedValue);
};
<Rating
initialRating={selectedRating}
onClick={onRatingSelected}
stop={11}
emptySymbol={fullSymbols}
fullSymbol={fullSymbols}
/>