Browse Source

fix #16 missing documentation: null/undefined as input value

main
Fanny Vieira 7 years ago
parent
commit
b20566ba96
  1. 19
      content/docs/controlled-input-null-value.md

19
content/docs/controlled-input-null-value.md

@ -0,0 +1,19 @@
---
id: controlled-input-null-value
title: Controlled input null value
permalink: docs/controlled-input-null-value.html
---
Specifying the value prop on a [controlled component](/docs/forms.html) prevents the user from changing the input unless you desire so.
You might have run into a problem where value is specified, but the input can still be changed without consent. In this case, you might have accidentally set value to undefined or null.
For example, this code shows this phenomenon; after a second, the text becomes editable.
```javascript
ReactDOM.render(<input value="hi" />, mountNode);
setTimeout(function() {
ReactDOM.render(<input value={null} />, mountNode);
}, 1000);
```
Loading…
Cancel
Save