Skip to content

Instantly share code, notes, and snippets.

@pomber
Created October 13, 2017 20:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pomber/3f5ca815d40d8954ea64be47a8f9e012 to your computer and use it in GitHub Desktop.
Save pomber/3f5ca815d40d8954ea64be47a8f9e012 to your computer and use it in GitHub Desktop.
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