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

Function callGetDerivedStateFromProps

code/composition/public/app.js:8626–8650  ·  view source on GitHub ↗
(workInProgress, instance, nextProps, prevState)

Source from the content-addressed store, hash-verified

8624 }
8625
8626 function callGetDerivedStateFromProps(workInProgress, instance, nextProps, prevState) {
8627 var type = workInProgress.type;
8628
8629
8630 if (typeof type.getDerivedStateFromProps === 'function') {
8631 if (debugRenderPhaseSideEffects || debugRenderPhaseSideEffectsForStrictMode && workInProgress.mode & StrictMode) {
8632 // Invoke method an extra time to help detect side-effects.
8633 type.getDerivedStateFromProps.call(null, nextProps, prevState);
8634 }
8635
8636 var partialState = type.getDerivedStateFromProps.call(null, nextProps, prevState);
8637
8638 {
8639 if (partialState === undefined) {
8640 var componentName = getComponentName(workInProgress) || 'Component';
8641 if (!didWarnAboutUndefinedDerivedState[componentName]) {
8642 warning(false, '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' + 'You have returned undefined.', componentName);
8643 didWarnAboutUndefinedDerivedState[componentName] = componentName;
8644 }
8645 }
8646 }
8647
8648 return partialState;
8649 }
8650 }
8651
8652 // Invokes the mount life-cycles on a previously never rendered instance.
8653 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