首页 > 其他 > 详细

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

时间:2021-07-09 12:52:19      阅读:17      评论:0      收藏:0      [点我收藏+]
来到了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;
      }
    }
  }

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!