You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
766 B
766 B
id | title | layout | permalink |
---|---|---|---|
controlled-input-null-value-tip | Value of null for controlled input | docs | controlled-input-null-value-tip.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.
/** @jsx React.DOM */
React.renderComponent(<input value="hi" />, mountNode);
setTimeout(function() {
React.renderComponent(<input value={null} />, mountNode);
}, 2000);