Chartjs-Getting a Chart is not defined ReferenceError with in React + React-chartjs

0👍

The problem might be that you never set the initial state of the component, so when componentDidUpdate tries to reference this.state, it doesn’t exist yet.

Try adding this:

getInitialState() {
    return { chart: null };
}

In a class you might need to use this instead:

constructor() {
    this.state = { chart: null };
}

Leave a comment