Javascript

初窥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;
      }
    }
  }

 

这篇关于初窥React-7(updateContainer方法-p2)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!