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

Function validateFunctionComponentInDev

packages/react-server/src/ReactFizzServer.js:2630–2667  ·  view source on GitHub ↗
(Component: any)

Source from the content-addressed store, hash-verified

2628}
2629
2630function validateFunctionComponentInDev(Component: any): void {
2631 if (__DEV__) {
2632 if (Component && Component.childContextTypes) {
2633 console.error(
2634 'childContextTypes cannot be defined on a function component.\n' +
2635 ' %s.childContextTypes = ...',
2636 Component.displayName || Component.name || 'Component',
2637 );
2638 }
2639
2640 if (typeof Component.getDerivedStateFromProps === 'function') {
2641 const componentName = getComponentNameFromType(Component) || 'Unknown';
2642
2643 if (!didWarnAboutGetDerivedStateOnFunctionComponent[componentName]) {
2644 console.error(
2645 '%s: Function components do not support getDerivedStateFromProps.',
2646 componentName,
2647 );
2648 didWarnAboutGetDerivedStateOnFunctionComponent[componentName] = true;
2649 }
2650 }
2651
2652 if (
2653 typeof Component.contextType === 'object' &&
2654 Component.contextType !== null
2655 ) {
2656 const componentName = getComponentNameFromType(Component) || 'Unknown';
2657
2658 if (!didWarnAboutContextTypeOnFunctionComponent[componentName]) {
2659 console.error(
2660 '%s: Function components do not support contextType.',
2661 componentName,
2662 );
2663 didWarnAboutContextTypeOnFunctionComponent[componentName] = true;
2664 }
2665 }
2666 }
2667}
2668
2669function renderForwardRef(
2670 request: Request,

Callers 1

renderFunctionComponentFunction · 0.70

Calls 2

getComponentNameFromTypeFunction · 0.85
errorMethod · 0.65

Tested by

no test coverage detected