I'm stumped, my react app isn't incrementing a counter as intended, instead of going 1,2,3,4,5, its going 1,11,111,1111,11111 ... My understanding is that you cant do this.state.count++ as that mutates the state which facebook says not to do, and they say to do this.state.count + 1. I'm fairly new to React and appreciate any help you can offer! Thanks!
import React, { Component } from 'react';
import './App.css';
class App extends Component {
constructor(){
super();
this.state = {
count: '0',
}
this.incrementCount = this.incrementCount.bind(this);
}
incrementCount() {
this.setState({
count: this.state.count + 1
});
}
render() {
return (
<div className='app'>
<div className='container'>
<button onClick={this.incrementCount}>Click to increase bid:
{this.state.count}</button>
</div>
</div>
);
}
}
export default App;