React 源码 - 高优先级如何插队

169 阅读1分钟
function dispatchAction(componentIdentity, queue, action);
const eventTime = requestEventTime();
const lane = requestUpdateLane(fiber);
const update: Update<S, A> = {
    lane,
    action,
    eagerReducer: null,
    eagerState: null,
    next: (null: any),
};

    |
    |
    V

scheduleUpdateOnFiber(fiber, lane, eventTime);
    |
    |
    V

ensureRootIsScheduled(root, eventTime);
// 获取优先级最高的 lane 此处,低优先级回被高优先级打断
const nextLanes = getNextLanes(
    root,
    root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes,
);
    |
    |
    V
......