I am trying to clone React elements like this to transfer parent details (in this example, no details are assigned):
React.createElement('div', { style: this.props.style }, React.cloneElement(this.props.children, null) )
This, however, returns the following error:
Inactive invariant violation: element type is invalid: a string is expected (for built-in components) or class / function (for composite components), but received: undefined.
If there is only one child, or if I pass React.cloneElement (this.props.children [0], null), then there is no error and the desired item will be displayed.
How can I clone multiple items?
source share