Document boolean attributes in JSX
Glen Mailer committed
May 15, 2015 at 10:12 UTC
0950f50753c2212007ab9683632dea5e18ebda0a
1 file changed
+14
docs/docs/02.1-jsx-in-depth.md
+14
@@ -176,6 +176,20 @@ var person = React.createElement(
176
);
177
```
178
179
+### Boolean Attributes
180
+
181
+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`.
182
+
183
+```javascript
184
+// These two are equivalent in JSX for disabling a button
185
+<input type="button" disabled />;
186
+<input type="button" disabled={true} />;
187
+
188
+// And these two are equivalent in JSX for not disabling a button
189
+<input type="button" />;
190
+<input type="button" disabled={false} />;
191
+```
192
+
193
### Child Expressions
194
195
Likewise, JavaScript expressions may be used to express children: