react-rating icon indicating copy to clipboard operation
react-rating copied to clipboard

Selection requires double click if onClick method provided

Open vedatsengul opened this issue 4 years ago • 3 comments
trafficstars

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

vedatsengul avatar Sep 22 '21 10:09 vedatsengul

For the people who are looking for a solution to this problem, my workaround is setting the initialRating in onClick.

vedatsengul avatar Sep 22 '21 11:09 vedatsengul

I have the same issue, would you share some sample code because in onClick we can't access to event

amastaneh avatar Dec 06 '21 16:12 amastaneh

@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}
          />

vedatsengul avatar Dec 06 '21 16:12 vedatsengul