ankane / react-chartkick

Create beautiful JavaScript charts with one line of React
https://chartkick.com/react
MIT License
1.2k stars 58 forks source link

Improvement - Updating props update existing chart instead of creating new one. #25

Closed papscript closed 6 years ago

papscript commented 6 years ago

Hi! First, thanks for the great lib! I've searched thorough a lot of react wrappers for some chart libs, and this one suits the best for me :)

I've spotted probably (I'm never sure ;p) unwanted behavior. When the props are updated component is creating new chartkick chart and don't destroy previous one. It can lead to great memory leak when for instance we're updating chart data in some interval.

So I've created this little pr to update existing chart instead of creating new one. It's working for the case I'm using it for.

I've tried to follow existing coding style. Although I'll be happy to make some changes if you want :)

Cheers

ankane commented 6 years ago

Awesome, thanks @PiotrekPaprocki 💯