1. 程式人生 > 其它 >初窺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; } } }