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

Function updateClassInstance

docs/external/js/react-dom.development.js:13288–13399  ·  view source on GitHub ↗
(current, workInProgress, ctor, newProps, renderExpirationTime)

Source from the content-addressed store, hash-verified

13286
13287
13288 function updateClassInstance(current, workInProgress, ctor, newProps, renderExpirationTime) {
13289 var instance = workInProgress.stateNode;
13290 cloneUpdateQueue(current, workInProgress);
13291 var oldProps = workInProgress.memoizedProps;
13292 instance.props = workInProgress.type === workInProgress.elementType ? oldProps : resolveDefaultProps(workInProgress.type, oldProps);
13293 var oldContext = instance.context;
13294 var contextType = ctor.contextType;
13295 var nextContext = emptyContextObject;
13296
13297 if (typeof contextType === 'object' && contextType !== null) {
13298 nextContext = readContext(contextType);
13299 } else {
13300 var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true);
13301 nextContext = getMaskedContext(workInProgress, nextUnmaskedContext);
13302 }
13303
13304 var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
13305 var hasNewLifecycles = typeof getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function'; // Note: During these life-cycles, instance.props/instance.state are what
13306 // ever the previously attempted to render - not the "current". However,
13307 // during componentDidUpdate we pass the "current" props.
13308 // In order to support react-lifecycles-compat polyfilled components,
13309 // Unsafe lifecycles should not be invoked for components using the new APIs.
13310
13311 if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
13312 if (oldProps !== newProps || oldContext !== nextContext) {
13313 callComponentWillReceiveProps(workInProgress, instance, newProps, nextContext);
13314 }
13315 }
13316
13317 resetHasForceUpdateBeforeProcessing();
13318 var oldState = workInProgress.memoizedState;
13319 var newState = instance.state = oldState;
13320 processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime);
13321 newState = workInProgress.memoizedState;
13322
13323 if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
13324 // If an update was already in progress, we should schedule an Update
13325 // effect even though we're bailing out, so that cWU/cDU are called.
13326 if (typeof instance.componentDidUpdate === 'function') {
13327 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
13328 workInProgress.effectTag |= Update;
13329 }
13330 }
13331
13332 if (typeof instance.getSnapshotBeforeUpdate === 'function') {
13333 if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
13334 workInProgress.effectTag |= Snapshot;
13335 }
13336 }
13337
13338 return false;
13339 }
13340
13341 if (typeof getDerivedStateFromProps === 'function') {
13342 applyDerivedStateFromProps(workInProgress, ctor, getDerivedStateFromProps, newProps);
13343 newState = workInProgress.memoizedState;
13344 }
13345

Callers 1

updateClassComponentFunction · 0.85

Calls 14

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

Tested by

no test coverage detected