MCPcopy Create free account
hub / github.com/microsoft/SandDance / applyDerivedStateFromProps

Function applyDerivedStateFromProps

docs/external/js/react-dom.development.js:12728–12754  ·  view source on GitHub ↗
(workInProgress, ctor, getDerivedStateFromProps, nextProps)

Source from the content-addressed store, hash-verified

12726 }
12727
12728 function applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, nextProps) {
12729 var prevState = workInProgress.memoizedState;
12730
12731 {
12732 if ( workInProgress.mode & StrictMode) {
12733 // Invoke the function an extra time to help detect side-effects.
12734 getDerivedStateFromProps(nextProps, prevState);
12735 }
12736 }
12737
12738 var partialState = getDerivedStateFromProps(nextProps, prevState);
12739
12740 {
12741 warnOnUndefinedDerivedState(ctor, partialState);
12742 } // Merge the partial state and the previous state.
12743
12744
12745 var memoizedState = partialState === null || partialState === undefined ? prevState : _assign({}, prevState, partialState);
12746 workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the
12747 // base state.
12748
12749 if (workInProgress.expirationTime === NoWork) {
12750 // Queue is always non-null for classes
12751 var updateQueue = workInProgress.updateQueue;
12752 updateQueue.baseState = memoizedState;
12753 }
12754 }
12755 var classComponentUpdater = {
12756 isMounted: isMounted,
12757 enqueueSetState: function (inst, payload, callback) {

Callers 4

mountClassInstanceFunction · 0.85
resumeMountClassInstanceFunction · 0.85
updateClassInstanceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected