August 2017
Beginner
298 pages
7h 4m
English
First, we'll attach the inputValue state with the input field. Inside your render() method, add the value attribute for the input JSX element, as shown in the following code:
<input type="text" name="newTask" value={this.state.inputValue} />
We have explicitly binded the value of the input field with the state variable. Now, try clicking Run and editing the input field. You should not be able to edit it.
This is because no matter what you type into this field, the render() method will simply render what we have specified in the return() statement, which is an input field with empty inputValue. So, how do we change the value of the input field? By adding an onChange attribute to the input field. Let me ...
Read now
Unlock full access