From 51fe7e466e1f21c1bd91c0490b77f31123d57aec Mon Sep 17 00:00:00 2001 From: Jess Telford Date: Tue, 16 Aug 2016 16:43:33 +1000 Subject: [PATCH] React.Children.toArray() changes keys (#7495) As noted by @spicyj in #5541 (cherry picked from commit aa48c82b0dd088730062b2904c64f91b3220dfcf) --- docs/docs/ref-01-top-level-api.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/docs/ref-01-top-level-api.md b/docs/docs/ref-01-top-level-api.md index c4e9b15d33d43..bb22b2bd620c2 100644 --- a/docs/docs/ref-01-top-level-api.md +++ b/docs/docs/ref-01-top-level-api.md @@ -132,6 +132,10 @@ array React.Children.toArray(object children) Return the `children` opaque data structure as a flat array with keys assigned to each child. Useful if you want to manipulate collections of children in your render methods, especially if you want to reorder or slice `this.props.children` before passing it down. +> Note: +> +> `React.Children.toArray()` changes keys to preserve the semantics of nested arrays when flattening lists of children. That is, `toArray` prefixes each key in the returned array so that each element's key is scoped to the input array containing it. + ## ReactDOM The `react-dom` package provides DOM-specific methods that can be used at the top level of your app and as an escape hatch to get outside of the React model if you need to. Most of your components should not need to use this module.