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

Function callGetDerivedStateFromProps

code/styling/public/app.js:8488–8512  ·  view source on GitHub ↗
(workInProgress, instance, nextProps, prevState)

Source from the content-addressed store, hash-verified

8486 }
8487
8488 function callGetDerivedStateFromProps(workInProgress, instance, nextProps, prevState) {
8489 var type = workInProgress.type;
8490
8491
8492 if (typeof type.getDerivedStateFromProps === 'function') {
8493 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
8494 // Invoke method an extra time to help detect side-effects.
8495 type.getDerivedStateFromProps.call(null, nextProps, prevState);
8496 }
8497
8498 var partialState = type.getDerivedStateFromProps.call(null, nextProps, prevState);
8499
8500 {
8501 if (partialState === undefined) {
8502 var componentName = getComponentName(workInProgress) || 'Component';
8503 if (!didWarnAboutUndefinedDerivedState[componentName]) {
8504 warning(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
8505 didWarnAboutUndefinedDerivedState[componentName] = componentName;
8506 }
8507 }
8508 }
8509
8510 return partialState;
8511 }
8512 }
8513
8514 // Invokes the mount life-cycles on a previously never rendered instance.
8515 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