Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function cloneElement(element, config, ...children) {
if (!isValidElement(element)) {
throw Error('cloneElement: not a valid element.');
}
// Original props are copied
const props = Object.assign({}, element.props);
// Reserved names are extracted
let key = element.key;
let ref = element.ref;
// Owner will be preserved, unless ref is overridden
let owner = element._owner;
if (config) {
// Should reset ref and owner if has a new ref
if (config.ref !== undefined) {