react-chartjs-2 icon indicating copy to clipboard operation
react-chartjs-2 copied to clipboard

Improve "Chart.js object" section in usage instructions

Open domehead100 opened this issue 7 years ago • 1 comments

The section on "Charts.js object" shows registering an inline plugin in componentWillMount(). This is not a good practice as written, since if the component is mounted and unmounted later, a new (duplicate) plugin will be registered every time. Also, componentWillMount can be triggered multiple times. Finally, this lifecycle method is deprecated in React 17.

As a note, I'm using typescript and it complains that react-chartjs-2 does not have an export "Chart", and indeed it doesn't in the index.d.ts file, though obviously the actual library code does (so this is just a typings issue). Rather than declare a custom module, I ended up importing Chart from chart.js itself, which works fine since Chart represents the global chart.js Chart object as far as I can tell.

domehead100 avatar Sep 07 '18 05:09 domehead100

I second this, having all the issues you are having atm.

ts-23 avatar Nov 28 '18 12:11 ts-23