MCPcopy Create free account
hub / github.com/plotly/dash / validateFunctionComponentInDev

Function validateFunctionComponentInDev

dash/deps/react-dom@18.3.1.js:20206–20266  ·  view source on GitHub ↗
(workInProgress, Component)

Source from the content-addressed store, hash-verified

20204 }
20205
20206 function validateFunctionComponentInDev(workInProgress, Component) {
20207 {
20208 if (Component) {
20209 if (Component.childContextTypes) {
20210 error('%s(...): childContextTypes cannot be defined on a function component.', Component.displayName || Component.name || 'Component');
20211 }
20212 }
20213
20214 if (workInProgress.ref !== null) {
20215 var info = '';
20216 var ownerName = getCurrentFiberOwnerNameInDevOrNull();
20217
20218 if (ownerName) {
20219 info += '\n\nCheck the render method of `' + ownerName + '`.';
20220 }
20221
20222 var warningKey = ownerName || '';
20223 var debugSource = workInProgress._debugSource;
20224
20225 if (debugSource) {
20226 warningKey = debugSource.fileName + ':' + debugSource.lineNumber;
20227 }
20228
20229 if (!didWarnAboutFunctionRefs[warningKey]) {
20230 didWarnAboutFunctionRefs[warningKey] = true;
20231
20232 error('Function components cannot be given refs. ' + 'Attempts to access this ref will fail. ' + 'Did you mean to use React.forwardRef()?%s', info);
20233 }
20234 }
20235
20236 if ( Component.defaultProps !== undefined) {
20237 var componentName = getComponentNameFromType(Component) || 'Unknown';
20238
20239 if (!didWarnAboutDefaultPropsOnFunctionComponent[componentName]) {
20240 error('%s: Support for defaultProps will be removed from function components ' + 'in a future major release. Use JavaScript default parameters instead.', componentName);
20241
20242 didWarnAboutDefaultPropsOnFunctionComponent[componentName] = true;
20243 }
20244 }
20245
20246 if (typeof Component.getDerivedStateFromProps === 'function') {
20247 var _componentName3 = getComponentNameFromType(Component) || 'Unknown';
20248
20249 if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
20250 error('%s: Function components do not support getDerivedStateFromProps.', _componentName3);
20251
20252 didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
20253 }
20254 }
20255
20256 if (typeof Component.contextType === 'object' && Component.contextType !== null) {
20257 var _componentName4 = getComponentNameFromType(Component) || 'Unknown';
20258
20259 if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
20260 error('%s: Function components do not support contextType.', _componentName4);
20261
20262 didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
20263 }

Callers 3

updateMemoComponentFunction · 0.70
mountLazyComponentFunction · 0.70

Calls 3

errorFunction · 0.70
getComponentNameFromTypeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…