MCPcopy Index your code
hub / github.com/microsoft/SandDance / checkClassInstance

Function checkClassInstance

docs/external/js/react-dom.development.js:12848–12953  ·  view source on GitHub ↗
(workInProgress, ctor, newProps)

Source from the content-addressed store, hash-verified

12846 }
12847
12848 function checkClassInstance(workInProgress, ctor, newProps) {
12849 var instance = workInProgress.stateNode;
12850
12851 {
12852 var name = getComponentName(ctor) || 'Component';
12853 var renderPresent = instance.render;
12854
12855 if (!renderPresent) {
12856 if (ctor.prototype && typeof ctor.prototype.render === 'function') {
12857 error('%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
12858 } else {
12859 error('%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
12860 }
12861 }
12862
12863 if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
12864 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);
12865 }
12866
12867 if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
12868 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);
12869 }
12870
12871 if (instance.propTypes) {
12872 error('propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
12873 }
12874
12875 if (instance.contextType) {
12876 error('contextType was defined as an instance property on %s. Use a static ' + 'property to define contextType instead.', name);
12877 }
12878
12879 {
12880 if (instance.contextTypes) {
12881 error('contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
12882 }
12883
12884 if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
12885 didWarnAboutContextTypeAndContextTypes.add(ctor);
12886
12887 error('%s declares both contextTypes and contextType static properties. ' + 'The legacy contextTypes property will be ignored.', name);
12888 }
12889 }
12890
12891 if (typeof instance.componentShouldUpdate === 'function') {
12892 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);
12893 }
12894
12895 if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
12896 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');
12897 }
12898
12899 if (typeof instance.componentDidUnmount === 'function') {
12900 error('%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);
12901 }
12902
12903 if (typeof instance.componentDidReceiveProps === 'function') {
12904 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);
12905 }

Callers 1

mountClassInstanceFunction · 0.85

Calls 5

getComponentNameFunction · 0.70
errorFunction · 0.70
isArrayFunction · 0.50
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected