MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / checkShouldComponentUpdate

Function checkShouldComponentUpdate

code/third-party/public/app.js:7505–7530  ·  view source on GitHub ↗
(workInProgress, oldProps, newProps, oldState, newState, newContext)

Source from the content-addressed store, hash-verified

7503 };
7504
7505 function checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext) {
7506 if (oldProps === null || workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate) {
7507 // If the workInProgress already has an Update effect, return true
7508 return true;
7509 }
7510
7511 var instance = workInProgress.stateNode;
7512 var ctor = workInProgress.type;
7513 if (typeof instance.shouldComponentUpdate === 'function') {
7514 startPhaseTimer(workInProgress, 'shouldComponentUpdate');
7515 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);
7516 stopPhaseTimer();
7517
7518 {
7519 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Component');
7520 }
7521
7522 return shouldUpdate;
7523 }
7524
7525 if (ctor.prototype && ctor.prototype.isPureReactComponent) {
7526 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
7527 }
7528
7529 return true;
7530 }
7531
7532 function checkClassInstance(workInProgress) {
7533 var instance = workInProgress.stateNode;

Callers 2

resumeMountClassInstanceFunction · 0.70
updateClassInstanceFunction · 0.70

Calls 6

warningFunction · 0.85
shouldComponentUpdateMethod · 0.80
startPhaseTimerFunction · 0.70
stopPhaseTimerFunction · 0.70
getComponentNameFunction · 0.70
shallowEqualFunction · 0.70

Tested by

no test coverage detected