MCPcopy
hub / github.com/facebook/react / jsonChildrenToJSXChildren

Function jsonChildrenToJSXChildren

packages/jest-react/src/JestReact.js:114–137  ·  view source on GitHub ↗
(jsonChildren)

Source from the content-addressed store, hash-verified

112}
113
114function jsonChildrenToJSXChildren(jsonChildren) {
115 if (jsonChildren !== null) {
116 if (jsonChildren.length === 1) {
117 return jsonChildToJSXChild(jsonChildren[0]);
118 } else if (jsonChildren.length > 1) {
119 const jsxChildren = [];
120 let allJSXChildrenAreStrings = true;
121 let jsxChildrenString = '';
122 for (let i = 0; i < jsonChildren.length; i++) {
123 const jsxChild = jsonChildToJSXChild(jsonChildren[i]);
124 jsxChildren.push(jsxChild);
125 if (allJSXChildrenAreStrings) {
126 if (typeof jsxChild === 'string') {
127 jsxChildrenString += jsxChild;
128 } else if (jsxChild !== null) {
129 allJSXChildrenAreStrings = false;
130 }
131 }
132 }
133 return allJSXChildrenAreStrings ? jsxChildrenString : jsxChildren;
134 }
135 }
136 return null;
137}

Callers 2

jsonChildToJSXChildFunction · 0.85

Calls 2

jsonChildToJSXChildFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected