From 65bf19029de40d3248b25f38e6af8982fbce454f Mon Sep 17 00:00:00 2001 From: Dmitry Zhuravlev-Nevsky Date: Tue, 10 Jan 2017 13:48:53 +0300 Subject: [PATCH] Swap components (#8735) It's better to delare component before using. --- docs/docs/jsx-in-depth.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/docs/jsx-in-depth.md b/docs/docs/jsx-in-depth.md index e08004d19f2f5..9cdd899cfda71 100644 --- a/docs/docs/jsx-in-depth.md +++ b/docs/docs/jsx-in-depth.md @@ -348,14 +348,6 @@ function Hello(props) { Normally, JavaScript expressions inserted in JSX will evaluate to a string, a React element, or a list of those things. However, `props.children` works just like any other prop in that it can pass any sort of data, not just the sorts that React knows how to render. For example, if you have a custom component, you could have it take a callback as `props.children`: ```js{4,13} -function ListOfTenThings() { - return ( - - {(index) =>
This is item {index} in the list
} -
- ); -} - // Calls the children callback numTimes to produce a repeated component function Repeat(props) { let items = []; @@ -364,6 +356,14 @@ function Repeat(props) { } return
{items}
; } + +function ListOfTenThings() { + return ( + + {(index) =>
This is item {index} in the list
} +
+ ); +} ``` Children passed to a custom component can be anything, as long as that component transforms them into something React can understand before rendering. This usage is not common, but it works if you want to stretch what JSX is capable of.