I am learning reactjs by creating a simple calculator that doubles a given number. When the callback to this.setState is called it has the existing value of this.state.amount and not the new value that was just entered.
handleAmountChange: function(event) {
this.setState({amount: event.target.value}, this.calculate());
},
calculate: function() {
this.setState({calculatedAmount: this.state.amount * 2});
}
What should be I be doing to get the most up to date version for this.state.amount in the calculate function?