NavigationReactMobile/sample/react-dom.js
// Invokes the update life-cycles and returns false if it shouldn't rerender.
Invokes the update life-cycles and returns false if it shouldn't rerender.
Invokes the update life - cycles and returns false if it shouldn ' t rerender .
function updateClassInstance(current, workInProgress, renderExpirationTime) {
    var ctor = workInProgress.type;
    var instance = workInProgress.stateNode;
    resetInputPointers(workInProgress, instance);
    var oldProps = workInProgress.memoizedProps;
    var newProps = workInProgress.pendingProps;
    var oldContext = instance.context;
    var newUnmaskedContext = getUnmaskedContext(workInProgress);
    var newContext = getMaskedContext(workInProgress, newUnmaskedContext);
    var hasNewLifecycles = typeof ctor.getDerivedStateFromProps === 'function' || typeof instance.getSnapshotBeforeUpdate === 'function';
    if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === 'function' || typeof instance.componentWillReceiveProps === 'function')) {
      if (oldProps !== newProps || oldContext !== newContext) {
        callComponentWillReceiveProps(workInProgress, instance, newProps, newContext);
      }
    }
    var oldState = workInProgress.memoizedState;
    var newState = void 0;
    var derivedStateFromCatch = void 0;
    if (workInProgress.updateQueue !== null) {
      newState = processUpdateQueue(current, workInProgress, workInProgress.updateQueue, instance, newProps, renderExpirationTime);
      var updateQueue = workInProgress.updateQueue;
      if (updateQueue !== null && updateQueue.capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor.getDerivedStateFromCatch === 'function') {
        var capturedValues = updateQueue.capturedValues;
        derivedStateFromCatch = callGetDerivedStateFromCatch(ctor, capturedValues);
      }
    } else {
      newState = oldState;
    }
    var derivedStateFromProps = void 0;
    if (oldProps !== newProps) {
      derivedStateFromProps = callGetDerivedStateFromProps(workInProgress, instance, newProps, newState);
    }
    if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) {
      newState = newState === null || newState === undefined ? derivedStateFromProps : _assign({}, newState, derivedStateFromProps);
    }
    if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) {
      newState = newState === null || newState === undefined ? derivedStateFromCatch : _assign({}, newState, derivedStateFromCatch);
    }
    if (oldProps === newProps && oldState === newState && !hasContextChanged() && !(workInProgress.updateQueue !== null && workInProgress.updateQueue.hasForceUpdate)) {
      if (typeof instance.componentDidUpdate === 'function') {
        if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
          workInProgress.effectTag |= Update;
        }
      }
      if (typeof instance.getSnapshotBeforeUpdate === 'function') {
        if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
          workInProgress.effectTag |= Snapshot;
        }
      }
      return false;
    }
    var shouldUpdate = checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);
    if (shouldUpdate) {
      if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === 'function' || typeof instance.componentWillUpdate === 'function')) {
        startPhaseTimer(workInProgress, 'componentWillUpdate');
        if (typeof instance.componentWillUpdate === 'function') {
          instance.componentWillUpdate(newProps, newState, newContext);
        }
        if (typeof instance.UNSAFE_componentWillUpdate === 'function') {
          instance.UNSAFE_componentWillUpdate(newProps, newState, newContext);
        }
        stopPhaseTimer();
      }
      if (typeof instance.componentDidUpdate === 'function') {
        workInProgress.effectTag |= Update;
      }
      if (typeof instance.getSnapshotBeforeUpdate === 'function') {
        workInProgress.effectTag |= Snapshot;
      }
    } else {
      if (typeof instance.componentDidUpdate === 'function') {
        if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
          workInProgress.effectTag |= Update;
        }
      }
      if (typeof instance.getSnapshotBeforeUpdate === 'function') {
        if (oldProps !== current.memoizedProps || oldState !== current.memoizedState) {
          workInProgress.effectTag |= Snapshot;
        }
      }
      memoizeProps(workInProgress, newProps);
      memoizeState(workInProgress, newState);
    }
    instance.props = newProps;
    instance.state = newState;
    instance.context = newContext;
    return shouldUpdate;
  }
function updateClassInstance ( current , workInProgress , renderExpirationTime ) { var ctor = workInProgress . type ; var instance = workInProgress . stateNode ; resetInputPointers ( workInProgress , instance ) ; var oldProps = workInProgress . memoizedProps ; var newProps = workInProgress . pendingProps ; var oldContext = instance . context ; var newUnmaskedContext = getUnmaskedContext ( workInProgress ) ; var newContext = getMaskedContext ( workInProgress , newUnmaskedContext ) ; var hasNewLifecycles = typeof ctor . getDerivedStateFromProps === 'function' || typeof instance . getSnapshotBeforeUpdate === 'function' ; if ( ! hasNewLifecycles && ( typeof instance . UNSAFE_componentWillReceiveProps === 'function' || typeof instance . componentWillReceiveProps === 'function' ) ) { if ( oldProps !== newProps || oldContext !== newContext ) { callComponentWillReceiveProps ( workInProgress , instance , newProps , newContext ) ; } } var oldState = workInProgress . memoizedState ; var newState = void 0 ; var derivedStateFromCatch = void 0 ; if ( workInProgress . updateQueue !== null ) { newState = processUpdateQueue ( current , workInProgress , workInProgress . updateQueue , instance , newProps , renderExpirationTime ) ; var updateQueue = workInProgress . updateQueue ; if ( updateQueue !== null && updateQueue . capturedValues !== null && enableGetDerivedStateFromCatch && typeof ctor . getDerivedStateFromCatch === 'function' ) { var capturedValues = updateQueue . capturedValues ; derivedStateFromCatch = callGetDerivedStateFromCatch ( ctor , capturedValues ) ; } } else { newState = oldState ; } var derivedStateFromProps = void 0 ; if ( oldProps !== newProps ) { derivedStateFromProps = callGetDerivedStateFromProps ( workInProgress , instance , newProps , newState ) ; } if ( derivedStateFromProps !== null && derivedStateFromProps !== undefined ) { newState = newState === null || newState === undefined ? derivedStateFromProps : _assign ( { } , newState , derivedStateFromProps ) ; } if ( derivedStateFromCatch !== null && derivedStateFromCatch !== undefined ) { newState = newState === null || newState === undefined ? derivedStateFromCatch : _assign ( { } , newState , derivedStateFromCatch ) ; } if ( oldProps === newProps && oldState === newState && ! hasContextChanged ( ) && ! ( workInProgress . updateQueue !== null && workInProgress . updateQueue . hasForceUpdate ) ) { if ( typeof instance . componentDidUpdate === 'function' ) { if ( oldProps !== current . memoizedProps || oldState !== current . memoizedState ) { workInProgress . effectTag |= Update ; } } if ( typeof instance . getSnapshotBeforeUpdate === 'function' ) { if ( oldProps !== current . memoizedProps || oldState !== current . memoizedState ) { workInProgress . effectTag |= Snapshot ; } } return false ; } var shouldUpdate = checkShouldComponentUpdate ( workInProgress , oldProps , newProps , oldState , newState , newContext ) ; if ( shouldUpdate ) { if ( ! hasNewLifecycles && ( typeof instance . UNSAFE_componentWillUpdate === 'function' || typeof instance . componentWillUpdate === 'function' ) ) { startPhaseTimer ( workInProgress , 'componentWillUpdate' ) ; if ( typeof instance . componentWillUpdate === 'function' ) { instance . componentWillUpdate ( newProps , newState , newContext ) ; } if ( typeof instance . UNSAFE_componentWillUpdate === 'function' ) { instance . UNSAFE_componentWillUpdate ( newProps , newState , newContext ) ; } stopPhaseTimer ( ) ; } if ( typeof instance . componentDidUpdate === 'function' ) { workInProgress . effectTag |= Update ; } if ( typeof instance . getSnapshotBeforeUpdate === 'function' ) { workInProgress . effectTag |= Snapshot ; } } else { if ( typeof instance . componentDidUpdate === 'function' ) { if ( oldProps !== current . memoizedProps || oldState !== current . memoizedState ) { workInProgress . effectTag |= Update ; } } if ( typeof instance . getSnapshotBeforeUpdate === 'function' ) { if ( oldProps !== current . memoizedProps || oldState !== current . memoizedState ) { workInProgress . effectTag |= Snapshot ; } } memoizeProps ( workInProgress , newProps ) ; memoizeState ( workInProgress , newState ) ; } instance . props = newProps ; instance . state = newState ; instance . context = newContext ; return shouldUpdate ; }
Invokes the update life-cycles and returns false if it shouldn't rerender.
Invokes the update life - cycles and returns false if it shouldn ' t rerender .
// Note: During these life-cycles, instance.props/instance.state are what // ever the previously attempted to render - not the "current". However, // during componentDidUpdate we pass the "current" props. // In order to support react-lifecycles-compat polyfilled components, // Unsafe lifecycles should not be invoked for components using the new APIs. // Compute the next state using the memoized state and the update queue. // TODO: Previous state can be null. // Don't remove these from the update queue yet. We need them in // finishClassComponent. Do the reset there. // TODO: This is awkward. Refactor class components. // updateQueue.capturedValues = null; // The prevState parameter should be the partially updated state. // Otherwise, spreading state in return values could override updates. // Render-phase updates (like this) should not be added to the update queue, // So that multiple render passes do not enqueue multiple updates. // Instead, just synchronously merge the returned state into the instance. // Render-phase updates (like this) should not be added to the update queue, // So that multiple render passes do not enqueue multiple updates. // Instead, just synchronously merge the returned state into the instance. // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. // In order to support react-lifecycles-compat polyfilled components, // Unsafe lifecycles should not be invoked for components using the new APIs. // If an update was already in progress, we should schedule an Update // effect even though we're bailing out, so that cWU/cDU are called. // If shouldComponentUpdate returned false, we should still update the // memoized props/state to indicate that this work can be reused. // Update the existing instance's state, props, and context pointers even // if shouldComponentUpdate returns false.