2013-10-02 12:03:44 +08:00
---
id: controlled-input-null-value
2013-10-31 03:06:16 +08:00
title: Value of null for Controlled Input
2013-11-12 13:00:53 +08:00
layout: tips
2013-10-02 12:03:44 +08:00
permalink: controlled-input-null-value.html
2013-10-31 03:06:16 +08:00
prev: children-props-type.html
2013-10-11 00:03:08 +08:00
next: componentWillReceiveProps-not-triggered-after-mounting.html
2013-10-02 12:03:44 +08:00
---
2013-11-13 04:59:59 +08:00
Specifying the `value` prop on a [controlled component ](/react/docs/forms.html ) prevents the user from changing the input unless you desire so.
2013-10-02 12:03:44 +08:00
2013-10-30 01:42:47 +08:00
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.
2013-10-02 12:03:44 +08:00
```js
2014-10-18 09:00:39 +08:00
React.render(< input value = "hi" / > , mountNode);
2013-10-02 12:03:44 +08:00
setTimeout(function() {
2014-10-18 09:00:39 +08:00
React.render(< input value = {null} / > , mountNode);
2014-04-16 04:45:09 +08:00
}, 1000);
2013-10-02 12:03:44 +08:00
```