MCPcopy Index your code
hub / github.com/react/react / warnOnFunctionTypeImpl

Function warnOnFunctionTypeImpl

packages/react-reconciler/src/ReactChildFiber.js:333–368  ·  view source on GitHub ↗
(returnFiber: Fiber, invalidChild: Function)

Source from the content-addressed store, hash-verified

331}
332
333function warnOnFunctionTypeImpl(returnFiber: Fiber, invalidChild: Function) {
334 if (__DEV__) {
335 const parentName = getComponentNameFromFiber(returnFiber) || 'Component';
336
337 if (ownerHasFunctionTypeWarning[parentName]) {
338 return;
339 }
340 ownerHasFunctionTypeWarning[parentName] = true;
341
342 const name = invalidChild.displayName || invalidChild.name || 'Component';
343
344 if (returnFiber.tag === HostRoot) {
345 console.error(
346 'Functions are not valid as a React child. This may happen if ' +
347 'you return %s instead of <%s /> from render. ' +
348 'Or maybe you meant to call this function rather than return it.\n' +
349 ' root.render(%s)',
350 name,
351 name,
352 name,
353 );
354 } else {
355 console.error(
356 'Functions are not valid as a React child. This may happen if ' +
357 'you return %s instead of <%s /> from render. ' +
358 'Or maybe you meant to call this function rather than return it.\n' +
359 ' <%s>{%s}</%s>',
360 name,
361 name,
362 parentName,
363 name,
364 parentName,
365 );
366 }
367 }
368}
369
370function warnOnFunctionType(returnFiber: Fiber, invalidChild: Function) {
371 const debugTask = getCurrentDebugTask();

Callers 1

warnOnFunctionTypeFunction · 0.85

Calls 2

errorMethod · 0.65

Tested by

no test coverage detected