What I am trying to do is, have multiple buttons to create different elements. The title is the error message that appear in my console when i run my app.
This is my codesandbox link that shows the code and error. Click on the link and open the console, the error is there
create chart function
onChartItem() {
/*eslint no-console: 0*/
console.log("adding", "n" + this.state.newCounter);
this.setState({
// Add a new item. It must have a unique key!
charts: this.state.charts.concat({
i: "n" + this.state.newCounter,
x: (this.state.charts.length * 2) % (this.state.cols || 12),
y: Infinity, // puts it at the bottom
w: 8,
h: 6
}),
// Increment the counter to ensure key is always unique.
newCounter: this.state.newCounter + 1
});
}
any advice is appreciated
I change this.onChartItem = this.onChartItem(this); to this this.onChartItem = this.onChartItem.bind(this);