auto build()

in ComponentKit/Core/Render/CKRenderHelpers.mm [256:319]


      auto build(id<CKRenderWithChildComponentProtocol> component,
                 __strong id<CKComponentProtocol> *childComponent,
                 CKTreeNode *parent,
                 CKTreeNode *_Nullable previousParent,
                 const CKBuildComponentTreeParams &params,
                 BOOL parentHasStateUpdate,
                 CKRenderDidReuseComponentBlock didReuseBlock) -> CKTreeNode *
      {
        RCCAssertNotNil(component, @"component cannot be nil");
        RCCAssertNotNil(parent, @"parent cannot be nil");

        // Context support
        CKComponentContextHelper::willBuildComponentTree(component);

        const auto pair = [CKTreeNode childPairForComponent:component
                                                     parent:parent
                                             previousParent:previousParent
                                                  scopeRoot:params.scopeRoot
                                               stateUpdates:params.stateUpdates];

        ThreadLocalStorageSupport tlsSupport(pair);

        auto const node = pair.node;

        // Faster Props updates and context support
        params.scopeRoot.rootNode.willBuildComponentTree(node);

        // Systrace logging
        [params.systraceListener willBuildComponent:component.typeName];

        // Faster state/props optimizations require previous parent.
        if (CKRenderInternal::reusePreviousComponentForSingleChild(node, component, childComponent, parent, previousParent, params, parentHasStateUpdate, didReuseBlock)) {
          CKRenderInternal::didBuildComponentTree(node, component, params);
          return node;
        }

        // Update the `parentHasStateUpdate` param for Faster state/props updates.
        parentHasStateUpdate = parentHasStateUpdate ||
        (params.buildTrigger == CKBuildTriggerStateUpdate &&
         CKRender::componentHasStateUpdate(node,
                                           previousParent,
                                           params.buildTrigger,
                                           params.stateUpdates));

        CK::CoalescedWillRenderRenderComponent(parentHasStateUpdate);

        auto const child = [component render:node.state];
        if (child) {
          if (childComponent != nullptr) {
            // Set the link between the parent to its child.
            *childComponent = child;
          }
          // Call build component tree on the child component.
          [child buildComponentTree:node
                     previousParent:[previousParent childForComponentKey:[node componentKey]]
                             params:params
               parentHasStateUpdate:parentHasStateUpdate];
        }

        CK::CoalescedDidRenderRenderComponent();
        CKRenderInternal::didBuildComponentTree(node, component, params);

        return node;
      }