Skip to main content

重点-updateContainer开始渲染-18

function updateContainer(element, container, parentComponent, callback) {
console.log('更新流程-->updateContainer本体')
{
onScheduleRoot(container, element);
}

var current$1 = container.current;
var eventTime = requestEventTime();
var lane = requestUpdateLane(current$1);

{
markRenderScheduled(lane);
}

var context = getContextForSubtree(parentComponent);

if (container.context === null) {
container.context = context;
} else {
container.pendingContext = context;
}

{
if (isRendering && current !== null && !didWarnAboutNestedUpdates) {
didWarnAboutNestedUpdates = true;

error('Render methods should be a pure function of props and state; ' + 'triggering nested component updates from render is not allowed. ' + 'If necessary, trigger nested updates in componentDidUpdate.\n\n' + 'Check the render method of %s.', getComponentNameFromFiber(current) || 'Unknown');
}
}

var update = createUpdate(eventTime, lane); // Caution: React DevTools currently depends on this property
// being called "element".

update.payload = {
element: element
};
callback = callback === undefined ? null : callback;

if (callback !== null) {
{
if (typeof callback !== 'function') {
error('render(...): Expected the last optional `callback` argument to be a ' + 'function. Instead received: %s.', callback);
}
}

update.callback = callback;
}

console.log('更新流程-->updateContainer本体,调用enqueueUpdate和scheduleUpdateOnFiber')
enqueueUpdate(current$1, update);
var root = scheduleUpdateOnFiber(current$1, lane, eventTime);

if (root !== null) {
entangleTransitions(root, current$1, lane);
}

return lane;
}