Value attribute


#1

What is the need of the attribute value in the input?

<input type="text" onChange={this.handleUserInput} value={this.state.userInput}/>
 <h1>{this.state.userInput}</h1>

Only the bind in the h1 already solve the problem, i guess…


#2

See the section on “Controlled Components”:


#3

Got it, thanks. The state of the input element must be updated too.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.