MCPcopy Create free account
hub / github.com/reactjs/react-rails / getStateFromUpdate

Function getStateFromUpdate

lib/assets/react-source/development/react.js:15938–16015  ·  view source on GitHub ↗
(workInProgress, queue, update, prevState, nextProps, instance)

Source from the content-addressed store, hash-verified

15936 }
15937
15938 function getStateFromUpdate(workInProgress, queue, update, prevState, nextProps, instance) {
15939 switch (update.tag) {
15940 case ReplaceState:
15941 {
15942 var payload = update.payload;
15943
15944 if (typeof payload === 'function') {
15945 // Updater function
15946 {
15947 enterDisallowedContextReadInDEV();
15948
15949 if ( workInProgress.mode & StrictMode) {
15950 payload.call(instance, prevState, nextProps);
15951 }
15952 }
15953
15954 var nextState = payload.call(instance, prevState, nextProps);
15955
15956 {
15957 exitDisallowedContextReadInDEV();
15958 }
15959
15960 return nextState;
15961 } // State object
15962
15963
15964 return payload;
15965 }
15966
15967 case CaptureUpdate:
15968 {
15969 workInProgress.effectTag = workInProgress.effectTag & ~ShouldCapture | DidCapture;
15970 }
15971 // Intentional fallthrough
15972
15973 case UpdateState:
15974 {
15975 var _payload = update.payload;
15976 var partialState;
15977
15978 if (typeof _payload === 'function') {
15979 // Updater function
15980 {
15981 enterDisallowedContextReadInDEV();
15982
15983 if ( workInProgress.mode & StrictMode) {
15984 _payload.call(instance, prevState, nextProps);
15985 }
15986 }
15987
15988 partialState = _payload.call(instance, prevState, nextProps);
15989
15990 {
15991 exitDisallowedContextReadInDEV();
15992 }
15993 } else {
15994 // Partial state object
15995 partialState = _payload;

Callers 1

processUpdateQueueFunction · 0.85

Tested by

no test coverage detected