Browse Source

adds returning multiple elements example to jsx-in-depth guide

main
James Clements 7 years ago
parent
commit
558ae3176a
  1. 14
      content/docs/jsx-in-depth.md

14
content/docs/jsx-in-depth.md

@ -308,7 +308,19 @@ You can mix together different types of children, so you can use string literals
</div>
```
A React component can't return multiple React elements, but a single JSX expression can have multiple children, so if you want a component to render multiple things you can wrap it in a `div` like this.
A React component can return multiple React elements:
```js
render() {
// No need to wrap list items in an extra element!
return [
// Don't forget the keys :)
<li key="A">First item</li>,
<li key="B">Second item</li>,
<li key="C">Third item</li>,
];
}
```
### JavaScript Expressions as Children

Loading…
Cancel
Save