react icon indicating copy to clipboard operation
react copied to clipboard

Controlled Components 'value' Not Being Reflected In The DOM

Open drizko opened this issue 10 years ago • 3 comments

I noticed that the input's value is not updated in the DOM when implementing a controlled component. Is this normal / expected behavior?

<div>
  <input
    // Controlled Component
    value={this.state.term}
    onChange={(event) => this.setState({ term: event.target.value })} />
</div>

Here is a link to an example on JSBin (When it first loads press 'Run with JS' button in Output section): http://jsbin.com/sodojo/1/edit?html,js,output

drizko avatar Jan 15 '16 16:01 drizko

Have you seen this~?

https://facebook.github.io/react/docs/forms.html

CoderK avatar Jan 15 '16 17:01 CoderK

@drizko You should read this: http://stackoverflow.com/questions/6003819/properties-and-attributes-in-html

yangshun avatar Jan 15 '16 17:01 yangshun

Thank you both for the resources, issue closed

drizko avatar Jan 15 '16 17:01 drizko