In React.js, I want to make a simple count button, where each click is a +1, but on the first click it still gives me 0, and only on the second click does it go up to 1, why is that? And how do I fix it?
class COUNT extends React.Component{
constructor(props){
super(props);
this.state = { count : 0 }
}
addNumber(){
setState({count: this.state.count+1})
console.log(this.state.count)
}
render(){
return(
<button onClick={() => addNumber()}>button</button>
)
}
}