Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const extractTypeName = node => {
const type = node.type.$$typeof;
if (type === Symbol.for('react.lazy')) {
return 'React.Lazy';
}
if (type === Symbol.for('react.memo')) {
return 'React.Memo';
}
if (node.type === Symbol.for('react.suspense')) {
return 'React.Suspense';
}
return typeName(node);
};
if (isNil(node) || node === false) {
return '';
}
if (Array.isArray(node)) {
return node.map(child => internalNodeToJson(child, options));
}
if (options.mode === 'deep' && typeof node.type === 'function') {
return internalNodeToJson(node.rendered, options);
}
return applyMap(
{
node,
type: typeName(node),
props: getProps(node, options),
children: getChildren(node, options),
$$typeof: Symbol.for('react.test.json'),
},
options,
);
}