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

Function checkShouldComponentUpdate

code/redux/public/app.js:8523–8548  ·  view source on GitHub ↗
(workInProgress, oldProps, newProps, oldState, newState, newContext)

Source from the content-addressed store, hash-verified

8521 };
8522
8523 function checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext) {
8524 if (oldProps === null || workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate) {
8525 // If the workInProgress already has an Update effect, return true
8526 return true;
8527 }
8528
8529 var instance = workInProgress.stateNode;
8530 var ctor = workInProgress.type;
8531 if (typeof instance.shouldComponentUpdate === 'function') {
8532 startPhaseTimer(workInProgress, 'shouldComponentUpdate');
8533 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);
8534 stopPhaseTimer();
8535
8536 {
8537 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Component');
8538 }
8539
8540 return shouldUpdate;
8541 }
8542
8543 if (ctor.prototype && ctor.prototype.isPureReactComponent) {
8544 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
8545 }
8546
8547 return true;
8548 }
8549
8550 function checkClassInstance(workInProgress) {
8551 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