From ea6d90ef327018d41b1f0fb712a0adb883312030 Mon Sep 17 00:00:00 2001 From: renatoselenica Date: Tue, 10 Oct 2017 16:39:39 +0200 Subject: [PATCH] Changed the documentation for React.Children.only to make its implementation simpler to understand. Fixes #87 --- content/docs/reference-react.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/content/docs/reference-react.md b/content/docs/reference-react.md index f12dbdde..95a0ab49 100644 --- a/content/docs/reference-react.md +++ b/content/docs/reference-react.md @@ -176,7 +176,11 @@ Returns the total number of components in `children`, equal to the number of tim React.Children.only(children) ``` -Returns the only child in `children`. Throws otherwise. +Verifies that `children` has only one child (a React element) and returns it. Otherwise this method throws. + +> Note: +> +>`React.Children.only()` does not accept the return value of [`React.Children.map()`](#reactchildrenmap) because it is an array rather than a React element. #### `React.Children.toArray`