Created
September 8, 2015 23:32
-
-
Save jsdf/658bb65211eb2bce54d7 to your computer and use it in GitHub Desktop.
Revisions
-
jsdf created this gist
Sep 8, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ import React from 'react'; export default function flattenReactChildrenToArray(nodeChildren, accumulated = []) { React.Children.forEach(nodeChildren, (childNode) => { accumulated.push(childNode); if (childNode && childNode.props && childNode.props.children) { flattenReactChildrenToArray(childNode.props.children, accumulated); } }); return accumulated; }