mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-25 23:05:23 +00:00
Merge pull request #3884 from glenjamin/patch-3
Document boolean attributes in JSX
This commit is contained in:
@@ -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
|
||||
<input type="button" disabled />;
|
||||
<input type="button" disabled={true} />;
|
||||
|
||||
// And these two are equivalent in JSX for not disabling a button
|
||||
<input type="button" />;
|
||||
<input type="button" disabled={false} />;
|
||||
```
|
||||
|
||||
### Child Expressions
|
||||
|
||||
Likewise, JavaScript expressions may be used to express children:
|
||||
|
||||
Reference in New Issue
Block a user