I\'m trying to create an input form that stores information in a component\'s state variable, then outputs that variable on the screen. I read the docs on controlled compone
Just call event.preventDefault method to prevent default behavior of form
event.preventDefault
afterSubmission(event) { event.preventDefault(); let name = this.state.itemName; this.setState ({ storedItemName:this.state.itemName }, function() { alert(this.state.storedItemName); // Shows the right value! } }