smastrom / react-rating

⭐ Zero-dependency, highly customizable rating component for React.
https://reactrating.netlify.app
MIT License
337 stars 6 forks source link

Setting default rating value causes first onChange value always be 0 #20

Closed andrewshvv closed 3 months ago

andrewshvv commented 4 months ago

Hey, the example from docs, but with default value of rating being non 0, causes first value of onChange handler be 0 ignoring the user input. Following updates of rating are correctly handled and corresponding user inputs are received in onChange handler.

smastrom commented 3 months ago

Hi @andrewshvv, while I trust that something is not working as expected, your issue is not clear enough and I can't look at it unless you provide some kind of reproduction of the expected behavior.

andrewshvv commented 3 months ago

@smastrom sure, here it is, click on 3rd star, it will show 0 https://playcode.io/1895956

smastrom commented 3 months ago

Hi @andrewshvv, this is expected. By default the rating can be reset (set to 0) when clicking on the current correspondent rating star using the mouse or the keyboard.

This behavior can be disabled by setting isRequired prop to true: https://reactrating.netlify.app/#required

andrewshvv commented 3 months ago

@smastrom thank u very much!