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

Function checkClassInstance

packages/react-reconciler/src/ReactFiberClassComponent.js:296–526  ·  view source on GitHub ↗
(workInProgress: Fiber, ctor: any, newProps: any)

Source from the content-addressed store, hash-verified

294}
295
296function checkClassInstance(workInProgress: Fiber, ctor: any, newProps: any) {
297 const instance = workInProgress.stateNode;
298 if (__DEV__) {
299 const name = getComponentNameFromType(ctor) || 'Component';
300 const renderPresent = instance.render;
301
302 if (!renderPresent) {
303 if (ctor.prototype && typeof ctor.prototype.render === 'function') {
304 console.error(
305 'No `render` method found on the %s ' +
306 'instance: did you accidentally return an object from the constructor?',
307 name,
308 );
309 } else {
310 console.error(
311 'No `render` method found on the %s ' +
312 'instance: you may have forgotten to define `render`.',
313 name,
314 );
315 }
316 }
317
318 if (
319 instance.getInitialState &&
320 !instance.getInitialState.isReactClassApproved &&
321 !instance.state
322 ) {
323 console.error(
324 'getInitialState was defined on %s, a plain JavaScript class. ' +
325 'This is only supported for classes created using React.createClass. ' +
326 'Did you mean to define a state property instead?',
327 name,
328 );
329 }
330 if (
331 instance.getDefaultProps &&
332 !instance.getDefaultProps.isReactClassApproved
333 ) {
334 console.error(
335 'getDefaultProps was defined on %s, a plain JavaScript class. ' +
336 'This is only supported for classes created using React.createClass. ' +
337 'Use a static property to define defaultProps instead.',
338 name,
339 );
340 }
341 if (instance.contextType) {
342 console.error(
343 'contextType was defined as an instance property on %s. Use a static ' +
344 'property to define contextType instead.',
345 name,
346 );
347 }
348
349 if (disableLegacyContext) {
350 if (ctor.childContextTypes && !didWarnAboutChildContextTypes.has(ctor)) {
351 didWarnAboutChildContextTypes.add(ctor);
352 console.error(
353 '%s uses the legacy childContextTypes API which was removed in React 19. ' +

Callers 1

mountClassInstanceFunction · 0.70

Calls 5

getComponentNameFromTypeFunction · 0.85
isArrayFunction · 0.85
addMethod · 0.80
errorMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected