entry on controlled input with value null

This commit is contained in:
Cheng Lou
2013-10-29 10:14:19 -07:00
committed by Connor McSheffrey
parent 9ed72b43e8
commit dd52ef92a8
2 changed files with 42 additions and 0 deletions
@@ -0,0 +1,20 @@
---
id: controlled-input-null-value-tip
title: Value of null for controlled input
layout: docs
permalink: controlled-input-null-value-tip.html
---
With a controlled input component, specifying a `value` prevents the user from changing the input unless you desire so (more info [here](forms.html)).
You might have ran into a problem where you specified a `value` but the input can still be changed. In this case, you might have accidentally set your `value` to `undefined` or `null`. The snippet below shows this phenomenon; after a second, the text be edited.
```js
/** @jsx React.DOM */
React.renderComponent(<input value="hi" />, mountNode);
setTimeout(function() {
React.renderComponent(<input value={null} />, mountNode);
}, 2000);
```
@@ -0,0 +1,22 @@
---
id: controlled-input-null-value
title: Value of null for controlled input
layout: docs
permalink: controlled-input-null-value.html
---
### Problem
You specified a `value` parameter for your form input, but the input value can still be modified, contrary to [what you'd expect](forms.html).
### Solution
You might have accidentally set your `value` to `undefined` or `null`. The snippet below shows this phenomenon; after a second, the text be edited.
```js
/** @jsx React.DOM */
React.renderComponent(<input value="hi" />, mountNode);
setTimeout(function() {
React.renderComponent(<input value={null} />, mountNode);
}, 2000);
```