From 6b0353ddc929cc4ac39c1aa6703f74f2bdb178ee Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 2 Oct 2013 00:03:44 -0400 Subject: [PATCH] entry on controlled input with `value` null --- .../cb-08-controlled-input-null-value tip.md | 20 +++++++++++++++++ cookbook/cb-08-controlled-input-null-value.md | 22 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 cookbook/cb-08-controlled-input-null-value tip.md create mode 100644 cookbook/cb-08-controlled-input-null-value.md diff --git a/cookbook/cb-08-controlled-input-null-value tip.md b/cookbook/cb-08-controlled-input-null-value tip.md new file mode 100644 index 00000000..acda5693 --- /dev/null +++ b/cookbook/cb-08-controlled-input-null-value tip.md @@ -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(, mountNode); + +setTimeout(function() { + React.renderComponent(, mountNode); +}, 2000); +``` diff --git a/cookbook/cb-08-controlled-input-null-value.md b/cookbook/cb-08-controlled-input-null-value.md new file mode 100644 index 00000000..b2d002aa --- /dev/null +++ b/cookbook/cb-08-controlled-input-null-value.md @@ -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(, mountNode); + +setTimeout(function() { + React.renderComponent(, mountNode); +}, 2000); +```