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

Revert rating to Old value

Open Chethannp opened this issue 5 years ago • 1 comments

Hi All,

In my scenario, When the user clicks on the star rating, I am trying to call an API to submit the latest value, All that I want to do is to revert to the original prop value when the API call fails.

My approach ->

I tried to use forwardRef to access all the child functionality and tried to overwrite the value by using the following

  1. this.childRatingComponentRef.current.props.onStarClick(previousValue) => This also fails and I can't even use this because once the rating is updating I am triggering a function in the parent to make an API cal, so if I do this above approach then I will fall in an endless loop ### :(
  2. this.childRatingComponentRef.current.state.value = 1; => Fails nothing happens and the position of the star is retained :(
  3. I did create another method called rollBackToPrevious and I am setting the state to the previous props value. => This also Fails :(

I am not sure on how to update the start component with a value dynamically from parent component.

Can anyone please help me !!!

Thanks in advance.

Chethannp avatar Aug 15 '19 13:08 Chethannp

This package is not being maintained. Do you want to take it over?

ninjasort avatar Nov 24 '19 15:11 ninjasort