初窥React-7(updateContainer方法-p2)

时间:2021-07-08
本文章向大家介绍初窥React-7(updateContainer方法-p2),主要包括初窥React-7(updateContainer方法-p2)使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
来到了update入栈了 enqueueUpdate(current$1, update);
function enqueueUpdate(fiber, update) { 
    var updateQueue = fiber.updateQueue; //取出当前的updateQueue

    if (updateQueue === null) {
      // Only occurs if the fiber has been unmounted.
      return;
    }

    var sharedQueue = updateQueue.shared;
    var pending = sharedQueue.pending;                

    //update插入到fiber的updateQueue.shared队列当中...
    if (pending === null) {
      // This is the first update. Create a circular list.
      update.next = update;
    } else {
      //入队 c- > a b之间
      update.next = pending.next;
      pending.next = update;
    }

    sharedQueue.pending = update;

    {
      if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) {
        error('An update (setState, replaceState, or forceUpdate) was scheduled ' + 'from inside an update function. Update functions should be pure, ' + 'with zero side-effects. Consider using componentDidUpdate or a ' + 'callback.');

        didWarnUpdateInsideUpdate = true;
      }
    }
  }

原文地址:https://www.cnblogs.com/allenliu0927/p/14988656.html