Incrementing state value by one using React
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. class QuestionList extends React.Component { constructor(props) { super(props); this.state = {value: 0}; // This binding is necessary to make `this` work in the callback this.handleClick = this.handleClick.bind(this); } handleClick = (prevState) => { this.setState({value: prevState.value + 1}); console.log(this.state.value) } Can you tell me why this is happening? it should be correct according to the docs here: https://facebook