MCPcopy Create free account
hub / github.com/reactjs/react-rails / checkClassInstance

Function checkClassInstance

lib/assets/react-source/development/react.js:16408–16513  ·  view source on GitHub ↗
(workInProgress, ctor, newProps)

Source from the content-addressed store, hash-verified

16406 }
16407
16408 function checkClassInstance(workInProgress, ctor, newProps) {
16409 var instance = workInProgress.stateNode;
16410
16411 {
16412 var name = getComponentName(ctor) || 'Component';
16413 var renderPresent = instance.render;
16414
16415 if (!renderPresent) {
16416 if (ctor.prototype && typeof ctor.prototype.render === 'function') {
16417 error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
16418 } else {
16419 error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
16420 }
16421 }
16422
16423 if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
16424 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);
16425 }
16426
16427 if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
16428 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);
16429 }
16430
16431 if (instance.propTypes) {
16432 error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
16433 }
16434
16435 if (instance.contextType) {
16436 error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name);
16437 }
16438
16439 {
16440 if (instance.contextTypes) {
16441 error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
16442 }
16443
16444 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
16445 didWarnAboutContextTypeAndContextTypes.add(ctor);
16446
16447 error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
16448 }
16449 }
16450
16451 if (typeof instance.componentShouldUpdate === 'function') {
16452 error('%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', name);
16453 }
16454
16455 if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
16456 error('%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(ctor) || 'A pure component');
16457 }
16458
16459 if (typeof instance.componentDidUnmount === 'function') {
16460 error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);
16461 }
16462
16463 if (typeof instance.componentDidReceiveProps === 'function') {
16464 error('%s has a method called ' + 'componentDidReceiveProps(). But there is no such lifecycle method. ' + 'If you meant to update the state in response to changing props, ' + 'use componentWillReceiveProps(). If you meant to fetch data or ' + 'run side-effects or mutations after React has updated the UI, use componentDidUpdate().', name);
16465 }

Callers 1

mountClassInstanceFunction · 0.85

Calls 2

getComponentNameFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected