Appendix
Appendix A – Propagating a context
React comes with different kinds of fibers. While a function component is one of them, the context provider is another one. It gets its own update logic with each update:
function updateContextProvider(fiber) { var providerType = fiber.type var context = providerType._context var newProps = fiber.pendingProps var oldProps = fiber.memoizedProps var newValue = newProps.value if (oldProps !== null) { ... } var children = newProps.children reconcileChildren(fiber, children) return fiber.child }
In the preceding code, the updateContextProvider
function takes in fiber
, and checks whether it has been mounted or not via oldProps !== null
. If it's a first-time mount, then it does things similar to a function component, reconciling the children into fibers and then returning the first child to work on next.
If it&apos...