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

Function checkShouldComponentUpdate

code/styling/public/app.js:8272–8297  ·  view source on GitHub ↗
(workInProgress, oldProps, newProps, oldState, newState, newContext)

Source from the content-addressed store, hash-verified

8270 };
8271
8272 function checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext) {
8273 if (oldProps === null || workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate) {
8274 // If the workInProgress already has an Update effect, return true
8275 return true;
8276 }
8277
8278 var instance = workInProgress.stateNode;
8279 var ctor = workInProgress.type;
8280 if (typeof instance.shouldComponentUpdate === 'function') {
8281 startPhaseTimer(workInProgress, 'shouldComponentUpdate');
8282 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);
8283 stopPhaseTimer();
8284
8285 {
8286 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Component');
8287 }
8288
8289 return shouldUpdate;
8290 }
8291
8292 if (ctor.prototype && ctor.prototype.isPureReactComponent) {
8293 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
8294 }
8295
8296 return true;
8297 }
8298
8299 function checkClassInstance(workInProgress) {
8300 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