Rater is not updating for some reason
r3wt opened this issue · 2 comments
As you can see in the image, an aggegration function updates the static read only rater, but for some reason this rater is not updating, even though the props show that a rating is provided. I'm not sure what is happening, any ideas?
code is simple its just:
<Rater total={5} interactive={false} rating={this.state.rating} />
Edit: after looking at the code of this library, i am suspecting this is due to UNSAFE_componentWillReceiveProps()
being the only method that the component updates.
I've made a temporary local fork of your codebase with the following workaround:
if(!interactive){
rating = restProps.rating;
}
this isn't an actual fix but i'm posting it here to illustrate the problem.
Hi @r3wt Thanks for reporting the issue. Sorry for not responding earlier.
For the case above, there could be another fix. If you want to force the static rater to re-render, try set a key
prop with rating as its value. For the code, I will consider update UNSAFE_componentWillReceiveProps
and move to getDerivedStateFromProps
. But it's expected to work if rating has changed, no matter whether the rater is interactive or not.
Without more information like the version you're using and more code, I'm cannot locate the cause of this issue. I'll close this first, but feel free to reopen it anytime.