Created
August 14, 2019 09:36
-
-
Save Tevinthuku/69d57093eb61746d2b85c26388a9880f to your computer and use it in GitHub Desktop.
performunitofwork
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... code | |
function performUnitOfWork(wipFiber) { | |
// lets work on the fiber | |
beginWork(wipFiber); | |
if (wipFiber.child) { | |
// if a child exists its passed on as | |
// the nextUnitOfWork | |
return wipFiber.child; | |
} | |
// No child, we call completeWork until we find a sibling | |
let uow = wipFiber; | |
while (uow) { | |
completeWork(uow); // completework on the currentFiber | |
// return the siblings of the currentFiber to | |
// be the nextUnitOfWork | |
if (uow.sibling) { | |
// Sibling needs to beginWork | |
return uow.sibling; | |
} | |
// if no siblings are present, | |
// lets climb up the tree as we call completeWork | |
// when no parent is found / if we've reached the top, | |
// this function returns null and thats how we know that we have completed | |
// working on the work in progress tree. | |
uow = uow.parent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment