Want to clone multiple children with React.cloneElement? children props is an opaque structure, it can be undefined, an array, or a single react element. You should use the React.Children utilities to map over the children structure :
1 2 3 4 5 6 | const style = this.props.style React.createElement('div', { style }, React.Children.map(this.props.children, (child => React.cloneElement(child, { style }))) ) |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.