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

Function callGetDerivedStateFromProps

code/communication/public/app.js:8523–8547  ·  view source on GitHub ↗
(workInProgress, instance, nextProps, prevState)

Source from the content-addressed store, hash-verified

8521 }
8522
8523 function callGetDerivedStateFromProps(workInProgress, instance, nextProps, prevState) {
8524 var type = workInProgress.type;
8525
8526
8527 if (typeof type.getDerivedStateFromProps === 'function') {
8528 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
8529 // Invoke method an extra time to help detect side-effects.
8530 type.getDerivedStateFromProps.call(null, nextProps, prevState);
8531 }
8532
8533 var partialState = type.getDerivedStateFromProps.call(null, nextProps, prevState);
8534
8535 {
8536 if (partialState === undefined) {
8537 var componentName = getComponentName(workInProgress) || 'Component';
8538 if (!didWarnAboutUndefinedDerivedState[componentName]) {
8539 warning(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
8540 didWarnAboutUndefinedDerivedState[componentName] = componentName;
8541 }
8542 }
8543 }
8544
8545 return partialState;
8546 }
8547 }
8548
8549 // Invokes the mount life-cycles on a previously never rendered instance.
8550 function mountClassInstance(workInProgress, renderExpirationTime) {

Callers 4

constructClassInstanceFunction · 0.70
resumeMountClassInstanceFunction · 0.70
updateClassInstanceFunction · 0.70

Calls 2

warningFunction · 0.85
getComponentNameFunction · 0.70

Tested by

no test coverage detected