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 beginWork(wipFiber) { | |
if (wipFiber.tag == CLASS_COMPONENT) { | |
updateClassComponent(wipFiber); | |
} else { | |
updateHostComponent(wipFiber); | |
} | |
} | |
function updateHostComponent(wipFiber) { | |
if (!wipFiber.stateNode) { | |
wipFiber.stateNode = createDomElement(wipFiber); | |
} | |
const newChildElements = wipFiber.props.children; | |
reconcileChildrenArray(wipFiber, newChildElements); | |
} | |
function updateClassComponent(wipFiber) { | |
let instance = wipFiber.stateNode; | |
if (instance == null) { | |
// Call class constructor | |
instance = wipFiber.stateNode = createInstance(wipFiber); | |
} else if (wipFiber.props == instance.props && !wipFiber.partialState) { | |
// No need to render, clone children from last time | |
cloneChildFibers(wipFiber); | |
return; | |
} | |
instance.props = wipFiber.props; | |
instance.state = Object.assign({}, instance.state, wipFiber.partialState); | |
wipFiber.partialState = null; | |
const newChildElements = wipFiber.stateNode.render(); | |
reconcileChildrenArray(wipFiber, newChildElements); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment