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
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 ### :(
this.childRatingComponentRef.current.state.value = 1; => Fails nothing happens and the position of the star is retained :(
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.
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
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.