smastrom/react-rating

Setting default rating value causes first onChange value always be 0

andrewshvv opened this issue · 4 comments

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.

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.

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

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

@smastrom thank u very much!