From 2b60d3c31fe36bdca2b4bd4ee9fced932eebf218 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Mon, 8 Jun 2015 13:28:39 -0700 Subject: [PATCH] Merge pull request #3884 from glenjamin/patch-3 Document boolean attributes in JSX --- docs/docs/02.1-jsx-in-depth.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/docs/02.1-jsx-in-depth.md b/docs/docs/02.1-jsx-in-depth.md index 64a7830d40..2c3143d2c8 100644 --- a/docs/docs/02.1-jsx-in-depth.md +++ b/docs/docs/02.1-jsx-in-depth.md @@ -176,6 +176,20 @@ var person = React.createElement( ); ``` +### Boolean Attributes + +Omitting the value of an attribute causes JSX to treat it as `true`. To pass `false` an attribute expression must be used. This often comes up when using HTML form elements, with attributes like `disabled`, `required`, `checked` and `readOnly`. + +```javascript +// These two are equivalent in JSX for disabling a button +; +; + +// And these two are equivalent in JSX for not disabling a button +; +; +``` + ### Child Expressions Likewise, JavaScript expressions may be used to express children: