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

Function checkShouldComponentUpdate

code/communication/public/app.js:8307–8332  ·  view source on GitHub ↗
(workInProgress, oldProps, newProps, oldState, newState, newContext)

Source from the content-addressed store, hash-verified

8305 };
8306
8307 function checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext) {
8308 if (oldProps === null || workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate) {
8309 // If the workInProgress already has an Update effect, return true
8310 return true;
8311 }
8312
8313 var instance = workInProgress.stateNode;
8314 var ctor = workInProgress.type;
8315 if (typeof instance.shouldComponentUpdate === 'function') {
8316 startPhaseTimer(workInProgress, 'shouldComponentUpdate');
8317 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);
8318 stopPhaseTimer();
8319
8320 {
8321 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Component');
8322 }
8323
8324 return shouldUpdate;
8325 }
8326
8327 if (ctor.prototype && ctor.prototype.isPureReactComponent) {
8328 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
8329 }
8330
8331 return true;
8332 }
8333
8334 function checkClassInstance(workInProgress) {
8335 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