Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert rating to Old value #62

Open
Chethannp opened this issue Aug 15, 2019 · 2 comments
Open

Revert rating to Old value #62

Chethannp opened this issue Aug 15, 2019 · 2 comments

Comments

@Chethannp
Copy link

Chethannp commented Aug 15, 2019

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
Copy link
Author

Can anyone respond please ?

@Chethanpremkumar
Copy link

Chethanpremkumar commented Aug 25, 2019

Can someone at least respond ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants