MCPcopy
hub / github.com/facebook/react / processUpdateQueue

Function processUpdateQueue

packages/react-server/src/ReactFizzClassComponent.js:586–623  ·  view source on GitHub ↗
(
  internalInstance: InternalInstance,
  inst: any,
  props: any,
  maskedLegacyContext: any,
)

Source from the content-addressed store, hash-verified

584}
585
586function processUpdateQueue(
587 internalInstance: InternalInstance,
588 inst: any,
589 props: any,
590 maskedLegacyContext: any,
591): void {
592 if (internalInstance.queue !== null && internalInstance.queue.length > 0) {
593 const oldQueue = internalInstance.queue;
594 const oldReplace = internalInstance.replace;
595 internalInstance.queue = null;
596 internalInstance.replace = false;
597
598 if (oldReplace && oldQueue.length === 1) {
599 inst.state = oldQueue[0];
600 } else {
601 let nextState = oldReplace ? oldQueue[0] : inst.state;
602 let dontMutate = true;
603 for (let i = oldReplace ? 1 : 0; i < oldQueue.length; i++) {
604 const partial = oldQueue[i];
605 const partialState =
606 typeof partial === 'function'
607 ? partial.call(inst, nextState, props, maskedLegacyContext)
608 : partial;
609 if (partialState != null) {
610 if (dontMutate) {
611 dontMutate = false;
612 nextState = assign({}, nextState, partialState);
613 } else {
614 assign(nextState, partialState);
615 }
616 }
617 }
618 inst.state = nextState;
619 }
620 } else {
621 internalInstance.queue = null;
622 }
623}
624
625// Invokes the mount life-cycles on a previously never rendered instance.
626export function mountClassInstance(

Callers 1

mountClassInstanceFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected