From 558ae3176a1ae32d5825e290b6f3a118da47c85f Mon Sep 17 00:00:00 2001 From: James Clements Date: Tue, 10 Oct 2017 16:45:26 -0500 Subject: [PATCH] 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 7acc3289..00a0e3a8 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