1
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import { isFunction } from './is';
|
||||
export function isFragment(child) {
|
||||
return child && /*#__PURE__*/React.isValidElement(child) && child.type === React.Fragment;
|
||||
}
|
||||
export const replaceElement = (element, replacement, props) => {
|
||||
if (! /*#__PURE__*/React.isValidElement(element)) {
|
||||
return replacement;
|
||||
}
|
||||
return /*#__PURE__*/React.cloneElement(element, isFunction(props) ? props(element.props || {}) : props);
|
||||
};
|
||||
export function cloneElement(element, props) {
|
||||
return replaceElement(element, element, props);
|
||||
}
|
||||
Reference in New Issue
Block a user