MCPcopy
hub / github.com/plotly/dash / updateClassInstance

Function updateClassInstance

dash/deps/react-dom@18.2.0.js:14648–14761  ·  view source on GitHub ↗
(current, workInProgress, ctor, newProps, renderLanes)

Source from the content-addressed store, hash-verified

14646
14647
14648 function updateClassInstance(current, workInProgress, ctor, newProps, renderLanes) {
14649 var instance = workInProgress.stateNode;
14650 cloneUpdateQueue(current, workInProgress);
14651 var unresolvedOldProps = workInProgress.memoizedProps;
14652 var oldProps = workInProgress.type === workInProgress.elementType ? unresolvedOldProps : resolveDefaultProps(workInProgress.type, unresolvedOldProps);
14653 instance.props = oldProps;
14654 var unresolvedNewProps = workInProgress.pendingProps;
14655 var oldContext = instance.context;
14656 var contextType = ctor.contextType;
14657 var nextContext = emptyContextObject;
14658
14659 if (typeof contextType === 'object' && contextType !== null) {
14660 nextContext = readContext(contextType);
14661 } else {
14662 var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
14663 nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
14664 }
14665
14666 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
14667 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
14668 // ever the previously attempted to render - not the "current". However,
14669 // during componentDidUpdate we pass the "current" props.
14670 // In order to support react-lifecycles-compat polyfilled components,
14671 // Unsafe lifecycles should not be invoked for components using the new APIs.
14672
14673 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
14674 if (unresolvedOldProps !== unresolvedNewProps || oldContext !== nextContext) {
14675 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
14676 }
14677 }
14678
14679 resetHasForceUpdateBeforeProcessing();
14680 var oldState = workInProgress.memoizedState;
14681 var newState = instance.state = oldState;
14682 processUpdateQueue(workInProgress, newProps, instance, renderLanes);
14683 newState = workInProgress.memoizedState;
14684
14685 if (unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing() && !(enableLazyContextPropagation )) {
14686 // If an update was already in progress, we should schedule an Update
14687 // effect even though we're bailing out, so that cWU/cDU are called.
14688 if (typeof instance.componentDidUpdate === 'function') {
14689 if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) {
14690 workInProgress.flags |= Update;
14691 }
14692 }
14693
14694 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
14695 if (unresolvedOldProps !== current.memoizedProps || oldState !== current.memoizedState) {
14696 workInProgress.flags |= Snapshot;
14697 }
14698 }
14699
14700 return false;
14701 }
14702
14703 if (typeof getDerivedStateFromProps === 'function') {
14704 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
14705 newState = workInProgress.memoizedState;

Callers 1

updateClassComponentFunction · 0.70

Calls 12

cloneUpdateQueueFunction · 0.70
resolveDefaultPropsFunction · 0.70
readContextFunction · 0.70
getUnmaskedContextFunction · 0.70
getMaskedContextFunction · 0.70
processUpdateQueueFunction · 0.70
hasContextChangedFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…