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

Function checkShouldComponentUpdate

code/event-handlers/public/app.js:7602–7627  ·  view source on GitHub ↗
(workInProgress, oldProps, newProps, oldState, newState, newContext)

Source from the content-addressed store, hash-verified

7600 };
7601
7602 function checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext) {
7603 if (oldProps === null || workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate) {
7604 // If the workInProgress already has an Update effect, return true
7605 return true;
7606 }
7607
7608 var instance = workInProgress.stateNode;
7609 var ctor = workInProgress.type;
7610 if (typeof instance.shouldComponentUpdate === 'function') {
7611 startPhaseTimer(workInProgress, 'shouldComponentUpdate');
7612 var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, newContext);
7613 stopPhaseTimer();
7614
7615 {
7616 warning(shouldUpdate !== undefined, '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', getComponentName(workInProgress) || 'Component');
7617 }
7618
7619 return shouldUpdate;
7620 }
7621
7622 if (ctor.prototype && ctor.prototype.isPureReactComponent) {
7623 return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
7624 }
7625
7626 return true;
7627 }
7628
7629 function checkClassInstance(workInProgress) {
7630 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