MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / checkClassInstance

Function checkClassInstance

code/composition/public/app.js:8437–8489  ·  view source on GitHub ↗
(workInProgress)

Source from the content-addressed store, hash-verified

8435 }
8436
8437 function checkClassInstance(workInProgress) {
8438 var instance = workInProgress.stateNode;
8439 var type = workInProgress.type;
8440 {
8441 var name = getComponentName(workInProgress) || 'Component';
8442 var renderPresent = instance.render;
8443
8444 if (!renderPresent) {
8445 if (type.prototype && typeof type.prototype.render === 'function') {
8446 warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: did you accidentally return an object from the constructor?', name);
8447 } else {
8448 warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`.', name);
8449 }
8450 }
8451
8452 var noGetInitialStateOnES6 = !instance.getInitialState || instance.getInitialState.isReactClassApproved || instance.state;
8453 warning(noGetInitialStateOnES6, '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);
8454 var noGetDefaultPropsOnES6 = !instance.getDefaultProps || instance.getDefaultProps.isReactClassApproved;
8455 warning(noGetDefaultPropsOnES6, '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);
8456 var noInstancePropTypes = !instance.propTypes;
8457 warning(noInstancePropTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', name);
8458 var noInstanceContextTypes = !instance.contextTypes;
8459 warning(noInstanceContextTypes, 'contextTypes was defined as an instance property on %s. Use a static ' + 'property to define contextTypes instead.', name);
8460 var noComponentShouldUpdate = typeof instance.componentShouldUpdate !== 'function';
8461 warning(noComponentShouldUpdate, '%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);
8462 if (type.prototype && type.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== 'undefined') {
8463 warning(false, '%s has a method called shouldComponentUpdate(). ' + 'shouldComponentUpdate should not be used when extending React.PureComponent. ' + 'Please extend React.Component if shouldComponentUpdate is used.', getComponentName(workInProgress) || 'A pure component');
8464 }
8465 var noComponentDidUnmount = typeof instance.componentDidUnmount !== 'function';
8466 warning(noComponentDidUnmount, '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', name);
8467 var noComponentDidReceiveProps = typeof instance.componentDidReceiveProps !== 'function';
8468 warning(noComponentDidReceiveProps, '%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);
8469 var noComponentWillRecieveProps = typeof instance.componentWillRecieveProps !== 'function';
8470 warning(noComponentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', name);
8471 var noUnsafeComponentWillRecieveProps = typeof instance.UNSAFE_componentWillRecieveProps !== 'function';
8472 warning(noUnsafeComponentWillRecieveProps, '%s has a method called ' + 'UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?', name);
8473 var hasMutatedProps = instance.props !== workInProgress.pendingProps;
8474 warning(instance.props === undefined || !hasMutatedProps, '%s(...): When calling super() in `%s`, make sure to pass ' + "up the same props that your component's constructor was passed.", name, name);
8475 var noInstanceDefaultProps = !instance.defaultProps;
8476 warning(noInstanceDefaultProps, 'Setting defaultProps as an instance property on %s is not supported and will be ignored.' + ' Instead, define defaultProps as a static property on %s.', name, name);
8477 var noInstanceGetDerivedStateFromProps = typeof instance.getDerivedStateFromProps !== 'function';
8478 warning(noInstanceGetDerivedStateFromProps, '%s: getDerivedStateFromProps() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
8479 var noInstanceGetDerivedStateFromCatch = typeof instance.getDerivedStateFromCatch !== 'function';
8480 warning(noInstanceGetDerivedStateFromCatch, '%s: getDerivedStateFromCatch() is defined as an instance method ' + 'and will be ignored. Instead, declare it as a static method.', name);
8481 var _state = instance.state;
8482 if (_state && (typeof _state !== 'object' || isArray(_state))) {
8483 warning(false, '%s.state: must be set to an object or null', name);
8484 }
8485 if (typeof instance.getChildContext === 'function') {
8486 warning(typeof type.childContextTypes === 'object', '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', name);
8487 }
8488 }
8489 }
8490
8491 function resetInputPointers(workInProgress, instance) {
8492 instance.props = workInProgress.memoizedProps;

Callers 1

mountClassInstanceFunction · 0.70

Calls 2

warningFunction · 0.85
getComponentNameFunction · 0.70

Tested by

no test coverage detected