requestIdleCallback(workLoop)
let rootFiber = {
...
}
let workInProgress = rootFiber
function workLoop(deadLine) {
while (workInProgress && deadLine.timeRemaining() > 1) {
workInProgress = performUnitOfWork(workInProgress)
}
commitRoot(rootFiber)
}
function performUnitOfWork (workInProgress) {
beginWork(workInProgress)
if (workInProgress.child) {
return workInProgress.child
}
while (workInProgress) {
completeUnitWork(workInProgress)
if (workInProgress.sibling) {
return workInProgress.sibling
}
workInProgress = workInProgress.return
}
}
function beginWork (workInProgress) {
let nextChildren = workInProgress.props.children
return reconcileChildren(workInProgress, nextChildren)
}
function reconcileChildren (returnFiber, nextChildren) {
for (let i = 0; i < nextChildren.length; i++) {
let newFiber = createFiber(nextChildren[i])
}
}
function createFiber(element) {
return {
tag: TAG_HOST,
type: element.type,
props: element.props,
key: element.key,
}
}
function completeUnitWork (workInProgress) {
switch(workInProgress.tag) {
case TAG_HOST:
createStateNode(workInProgress)
}
makeEffectList(workInProgress)
}
function makeEffectList (workInProgress) {
}
function commitRoot (rootFiber) {
let currentEffect = rootFiber.firstEffect
while (currentEffect) {
switch(currentEffect.flags) {
case Placement:
commitPlacemen(currentEffect)
}
currentEffect = currentEffect.nextEffect
}
}
function commitPlacemen (currentEffect) {
let parent = currentEffect.return.stateNode
parent.appendChild(currentEffect.stateNode)
}