n49 / react-stars

A simple star rating component for your React projects :star:
http://developers.n49.com/react-stars/
218 stars 82 forks source link

Component doesn't re-render when sent new props #13

Open PAK90 opened 7 years ago

PAK90 commented 7 years ago

I'm using the {...starSettings} method of passing props, one of which is the edit prop. After manually fixing the edit override issue (#12), I expected it to re-render if I passed it a changed prop. In this case, it doesn't re-render, leaving it stuck in an edit true/false state until I refresh my page. From my understanding of react, if a prop changes, it should force a re-render? In the React tab of chrome dev tools, I can confirm that my state value changes from true to false and vice versa (the state value that's assigned to the edit prop), but this doesn't seem to affect the ReactStars component, since its edit prop stays at the initially rendered value.

edit: After poking the code a bit more, changing all the occurrences of config.edit to this.props.edit fixes the issue. Not sure why, but there's something wrong with the way the state (and therefore config) is assigned values.

fedoryakubovich commented 6 years ago

43