(tree: Element<*>, key?: string)
| 73 | } |
| 74 | |
| 75 | const convertComponent = (tree: Element<*>, key?: string) => { |
| 76 | if (typeof tree.key === 'string') { |
| 77 | key = tree.key |
| 78 | } |
| 79 | |
| 80 | const { name, type } = processMeta(tree) |
| 81 | if (type === 'unknown') { |
| 82 | return { |
| 83 | type: 'Unsupported', |
| 84 | props: { |
| 85 | children: [], |
| 86 | }, |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | const props = processProps(tree.props) |
| 91 | if (type === 'function') { |
| 92 | return convertComponent(tree.type(props), key) |
| 93 | } |
| 94 | |
| 95 | const children = convertChildren(props.children) |
| 96 | return { |
| 97 | type: name, |
| 98 | props: { ...props, children, key }, |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return convertComponent(tree) |
| 103 | } |
no test coverage detected