Skip to content

Commit 38ec8dd

Browse files
authored
Merge pull request reactjs#127 from jamesvclements/jsx-in-depth-multiple-elements
adds returning multiple elements example to jsx-in-depth guide
2 parents c6076da + f81cf01 commit 38ec8dd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

content/docs/jsx-in-depth.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,19 @@ You can mix together different types of children, so you can use string literals
308308
</div>
309309
```
310310

311-
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.
311+
A React component can also return an array of elements:
312+
313+
```js
314+
render() {
315+
// No need to wrap list items in an extra element!
316+
return [
317+
// Don't forget the keys :)
318+
<li key="A">First item</li>,
319+
<li key="B">Second item</li>,
320+
<li key="C">Third item</li>,
321+
];
322+
}
323+
```
312324

313325
### JavaScript Expressions as Children
314326

0 commit comments

Comments
 (0)