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

Function checkClassInstance

dash/deps/react-dom@18.3.1.js:18031–18152  ·  view source on GitHub ↗
(workInProgress, ctor, newProps)

Source from the content-addressed store, hash-verified

18029 }
18030
18031 function checkClassInstance(workInProgress, ctor, newProps) {
18032 var instance = workInProgress.stateNode;
18033
18034 {
18035 var name = getComponentNameFromType(ctor) || 'Component';
18036 var renderPresent = instance.render;
18037
18038 if (!renderPresent) {
18039 if (ctor.prototype && typeof ctor.prototype.render === 'function') {
18040 error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
18041 } else {
18042 error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
18043 }
18044 }
18045
18046 if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
18047 error('getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', name);
18048 }
18049
18050 if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
18051 error('getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', name);
18052 }
18053
18054 if (instance.propTypes) {
18055 error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
18056 }
18057
18058 if (instance.contextType) {
18059 error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name);
18060 }
18061
18062 {
18063 if (ctor.childContextTypes && !didWarnAboutLegacyContext$1.has(ctor) && // Strict Mode has its own warning for legacy context, so we can skip
18064 // this one.
18065 (workInProgress.mode & StrictLegacyMode) === NoMode) {
18066 didWarnAboutLegacyContext$1.add(ctor);
18067
18068 error('%s uses the legacy childContextTypes API which is no longer ' + 'supported and will be removed in the next major release. Use ' + 'React.createContext() instead\n\n.' + 'Learn more about this warning here: https://reactjs.org/link/legacy-context', name);
18069 }
18070
18071 if (ctor.contextTypes && !didWarnAboutLegacyContext$1.has(ctor) && // Strict Mode has its own warning for legacy context, so we can skip
18072 // this one.
18073 (workInProgress.mode & StrictLegacyMode) === NoMode) {
18074 didWarnAboutLegacyContext$1.add(ctor);
18075
18076 error('%s uses the legacy contextTypes API which is no longer supported ' + 'and will be removed in the next major release. Use ' + 'React.createContext() with static contextType instead.\n\n' + 'Learn more about this warning here: https://reactjs.org/link/legacy-context', name);
18077 }
18078
18079 if (instance.contextTypes) {
18080 error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
18081 }
18082
18083 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
18084 didWarnAboutContextTypeAndContextTypes.add(ctor);
18085
18086 error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
18087 }
18088 }

Callers 1

mountClassInstanceFunction · 0.70

Calls 4

getComponentNameFromTypeFunction · 0.70
errorFunction · 0.70
isArrayFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…