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 elementToTree(el) {
if (el === null || typeof el !== 'object' || !('type' in el)) {
return el;
}
const {
type,
props,
key,
ref,
} = el;
const { children } = props;
let rendered = null;
if (isArrayLike(children)) {
rendered = flatten([...children]).map(elementToTree);
} else if (typeof children !== 'undefined') {
rendered = elementToTree(children);
}
const nodeType = nodeTypeFromType(type);
if (nodeType === 'host' && props.dangerouslySetInnerHTML) {
if (props.children != null) {
const error = new Error('Can only set one of `children` or `props.dangerouslySetInnerHTML`.');
error.name = 'Invariant Violation';
throw error;
}
}
return {