MCPcopy Index your code
hub / github.com/microsoft/SandDance / updateReducer

Function updateReducer

docs/external/js/react-dom.development.js:15172–15297  ·  view source on GitHub ↗
(reducer, initialArg, init)

Source from the content-addressed store, hash-verified

15170 }
15171
15172 function updateReducer(reducer, initialArg, init) {
15173 var hook = updateWorkInProgressHook();
15174 var queue = hook.queue;
15175
15176 if (!(queue !== null)) {
15177 {
15178 throw Error( "Should have a queue. This is likely a bug in React. Please file an issue." );
15179 }
15180 }
15181
15182 queue.lastRenderedReducer = reducer;
15183 var current = currentHook; // The last rebase update that is NOT part of the base state.
15184
15185 var baseQueue = current.baseQueue; // The last pending update that hasn't been processed yet.
15186
15187 var pendingQueue = queue.pending;
15188
15189 if (pendingQueue !== null) {
15190 // We have new updates that haven't been processed yet.
15191 // We'll add them to the base queue.
15192 if (baseQueue !== null) {
15193 // Merge the pending queue and the base queue.
15194 var baseFirst = baseQueue.next;
15195 var pendingFirst = pendingQueue.next;
15196 baseQueue.next = pendingFirst;
15197 pendingQueue.next = baseFirst;
15198 }
15199
15200 current.baseQueue = baseQueue = pendingQueue;
15201 queue.pending = null;
15202 }
15203
15204 if (baseQueue !== null) {
15205 // We have a queue to process.
15206 var first = baseQueue.next;
15207 var newState = current.baseState;
15208 var newBaseState = null;
15209 var newBaseQueueFirst = null;
15210 var newBaseQueueLast = null;
15211 var update = first;
15212
15213 do {
15214 var updateExpirationTime = update.expirationTime;
15215
15216 if (updateExpirationTime < renderExpirationTime) {
15217 // Priority is insufficient. Skip this update. If this is the first
15218 // skipped update, the previous update/state is the new base
15219 // update/state.
15220 var clone = {
15221 expirationTime: update.expirationTime,
15222 suspenseConfig: update.suspenseConfig,
15223 action: update.action,
15224 eagerReducer: update.eagerReducer,
15225 eagerState: update.eagerState,
15226 next: null
15227 };
15228
15229 if (newBaseQueueLast === null) {

Callers 2

updateStateFunction · 0.85

Calls 5

updateWorkInProgressHookFunction · 0.85
reducerFunction · 0.85

Tested by

no test coverage detected