Created
October 13, 2017 20:09
-
-
Save pomber/3f5ca815d40d8954ea64be47a8f9e012 to your computer and use it in GitHub Desktop.
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
function resetNextUnitOfWork() { | |
const update = updateQueue.shift(); | |
if (!update) { | |
return; | |
} | |
// Copy the setState parameter from the update payload to the corresponding fiber | |
if (update.partialState) { | |
update.instance.__fiber.partialState = update.partialState; | |
} | |
const root = | |
update.from == HOST_ROOT | |
? update.dom._rootContainerFiber | |
: getRoot(update.instance.__fiber); | |
nextUnitOfWork = { | |
tag: HOST_ROOT, | |
stateNode: update.dom || root.stateNode, | |
props: update.newProps || root.props, | |
alternate: root | |
}; | |
} | |
function getRoot(fiber) { | |
let node = fiber; | |
while (node.parent) { | |
node = node.parent; | |
} | |
return node; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment