In React I am trying to make a button increment a value stored in state. However using the code below function my value is set undefined or NaN when using handleClick.
import React from 'react'
class App extends React.Component{
constructor(){
super()
this.state = {
count: 0
}
this.handleClick = this.handleClick.bind(this)
}
handleClick(){
this.setState(prevState => {
return {
count: prevState.count + 1
}
})
}
render(){
return(
{this.state.count}
)
}
}
export default App