MCPcopy Create free account
hub / github.com/MainframeOS/react-json-renderer / convertComponent

Function convertComponent

src/converter.js:75–100  ·  view source on GitHub ↗
(tree: Element<*>, key?: string)

Source from the content-addressed store, hash-verified

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}

Callers 2

convertChildFunction · 0.85
convertToObjectFunction · 0.85

Calls 2

processPropsFunction · 0.85
convertChildrenFunction · 0.85

Tested by

no test coverage detected