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

Function getChildren

packages/react-test-renderer/src/ReactTestRenderer.js:260–296  ·  view source on GitHub ↗
(parent: Fiber)

Source from the content-addressed store, hash-verified

258]);
259
260function getChildren(parent: Fiber) {
261 const children = [];
262 const startingNode = parent;
263 let node: Fiber = startingNode;
264 if (node.child === null) {
265 return children;
266 }
267 node.child.return = node;
268 node = node.child;
269 outer: while (true) {
270 let descend = false;
271 if (validWrapperTypes.has(node.tag)) {
272 children.push(wrapFiber(node));
273 } else if (node.tag === HostText) {
274 if (__DEV__) {
275 checkPropStringCoercion(node.memoizedProps, 'memoizedProps');
276 }
277 children.push('' + node.memoizedProps);
278 } else {
279 descend = true;
280 }
281 if (descend && node.child !== null) {
282 node.child.return = node;
283 node = node.child;
284 continue;
285 }
286 while (node.sibling === null) {
287 if (node.return === startingNode) {
288 break outer;
289 }
290 node = (node.return: any);
291 }
292 (node.sibling: any).return = node.return;
293 node = (node.sibling: any);
294 }
295 return children;
296}
297
298class ReactTestInstance {
299 _fiber: Fiber;

Callers 3

parentMethod · 0.70
childrenMethod · 0.70
createFunction · 0.70

Calls 4

checkPropStringCoercionFunction · 0.90
wrapFiberFunction · 0.85
hasMethod · 0.65
pushMethod · 0.65

Tested by

no test coverage detected