react-sparklines icon indicating copy to clipboard operation
react-sparklines copied to clipboard

SparklinesLines doesn't re-render if 'color' prop changes

Open CodyReichert opened this issue 8 years ago • 2 comments

I put up a simple demo to reproduce the issue here: http://www.webpackbin.com/N1tuFIpfZ

If I have something like this:

<Sparklines data={this.props.data}>
    <SparklinesLine color={this.props.color} />
</Sparklines>

// where data = [1,2,1,2,1]
//           color = "blue"

and i update this.props.color, but I don't update this.props.data - then SparklinesLine does not re-render and the color doesn't change.

If i change the data and the color, they both update correctly.

I believe this issue is similar to the other few that are open regarding the shouldComponentUpdate function in Sparklines component.


If you go to the demo above and run, the color is changed but the Sparkline doesn't update. If you change the data prop inside the code - you will see that it updates both the data and the color correctly.

CodyReichert avatar May 24 '16 15:05 CodyReichert

If I set this to always return true, everything updates as expected: https://github.com/borisyankov/react-sparklines/blob/master/src/Sparklines.js#L42

CodyReichert avatar May 24 '16 15:05 CodyReichert

OK - I can confirm that using the master branch react-sparklines@borisyankov/react-sparklines does fix the issue.

All that needs to happen is a new release be built and published.

Let me know if I can help or provide any other info.

CodyReichert avatar May 24 '16 16:05 CodyReichert