From 558ae3176a1ae32d5825e290b6f3a118da47c85f Mon Sep 17 00:00:00 2001 From: James Clements Date: Tue, 10 Oct 2017 16:45:26 -0500 Subject: [PATCH 1/3] adds returning multiple elements example to jsx-in-depth guide --- content/docs/jsx-in-depth.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/content/docs/jsx-in-depth.md b/content/docs/jsx-in-depth.md index 7acc32892e5..00a0e3a8277 100644 --- a/content/docs/jsx-in-depth.md +++ b/content/docs/jsx-in-depth.md @@ -308,7 +308,19 @@ You can mix together different types of children, so you can use string literals ``` -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 :) +
  • First item
  • , +
  • Second item
  • , +
  • Third item
  • , + ]; +} +``` ### JavaScript Expressions as Children From 5f2cadf8657023e331f379b21e8eaa937f26178a Mon Sep 17 00:00:00 2001 From: James Clements Date: Tue, 10 Oct 2017 16:49:46 -0500 Subject: [PATCH 2/3] any elements --- content/docs/jsx-in-depth.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/jsx-in-depth.md b/content/docs/jsx-in-depth.md index 00a0e3a8277..9cd73c1c0af 100644 --- a/content/docs/jsx-in-depth.md +++ b/content/docs/jsx-in-depth.md @@ -308,7 +308,7 @@ You can mix together different types of children, so you can use string literals ``` -A React component can return multiple React elements: +A React component can return multiple elements: ```js render() { From f81cf014f59a8aed971b3c28b776e3c33f7db661 Mon Sep 17 00:00:00 2001 From: James Clements Date: Tue, 10 Oct 2017 17:06:12 -0500 Subject: [PATCH 3/3] change wording to reflect array --- content/docs/jsx-in-depth.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/docs/jsx-in-depth.md b/content/docs/jsx-in-depth.md index 9cd73c1c0af..fafbe64d3f8 100644 --- a/content/docs/jsx-in-depth.md +++ b/content/docs/jsx-in-depth.md @@ -308,7 +308,7 @@ You can mix together different types of children, so you can use string literals ``` -A React component can return multiple elements: +A React component can also return an array of elements: ```js render() {