Files
react/docs/tips/08-controlled-input-null-value.md
T
Paul O’Shannessy dfebed11c2 Merge pull request #7308 from zpao/jekyll3
Upgrade to Jekyll 3
(cherry picked from commit 5e3959e071)
2016-07-19 16:36:23 -07:00

816 B

id, title, layout, permalink, prev, next
id title layout permalink prev next
controlled-input-null-value Value of null for Controlled Input tips tips/controlled-input-null-value.html children-props-type.html componentWillReceiveProps-not-triggered-after-mounting.html

Specifying the value prop on a controlled component 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.

The snippet below shows this phenomenon; after a second, the text becomes editable.

ReactDOM.render(<input value="hi" />, mountNode);

setTimeout(function() {
  ReactDOM.render(<input value={null} />, mountNode);
}, 1000);