mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Changelog: [internal] 1. Creates `ShadowNodeFamily` inside `ComponentDescriptor`. 2. As a side effect of this, we no longer need `ComponentDescriptor::createEventEmitter` so it is removed. This is a step in order to merge `StateCoordinator` into `ShadowNodeFamily` and use it as target for state updates. Reviewed By: shergin Differential Revision: D19514906 fbshipit-source-id: 04ad3c621886be56925acd76f9b35a09d8c5e15a
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "ComponentBuilder.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
ComponentBuilder::ComponentBuilder(
|
|
ComponentDescriptorRegistry::Shared const &componentDescriptorRegistry)
|
|
: componentDescriptorRegistry_(componentDescriptorRegistry){};
|
|
|
|
ShadowNode::Shared ComponentBuilder::build(
|
|
ElementFragment const &elementFragment) const {
|
|
auto &componentDescriptor =
|
|
componentDescriptorRegistry_->at(elementFragment.componentHandle);
|
|
|
|
auto children = ShadowNode::ListOfShared{};
|
|
children.reserve(elementFragment.children.size());
|
|
for (auto const &childFragment : elementFragment.children) {
|
|
children.push_back(build(childFragment));
|
|
}
|
|
|
|
auto family = componentDescriptor.createFamily(
|
|
ShadowNodeFamilyFragment{
|
|
elementFragment.tag, elementFragment.surfaceId, nullptr},
|
|
nullptr);
|
|
|
|
auto shadowNode = componentDescriptor.createShadowNode(
|
|
ShadowNodeFragment{
|
|
elementFragment.props,
|
|
std::make_shared<ShadowNode::ListOfShared const>(children),
|
|
elementFragment.state},
|
|
family);
|
|
|
|
if (elementFragment.referenceCallback) {
|
|
elementFragment.referenceCallback(shadowNode);
|
|
}
|
|
|
|
if (elementFragment.finalizeCallback) {
|
|
elementFragment.finalizeCallback(const_cast<ShadowNode &>(*shadowNode));
|
|
}
|
|
|
|
return shadowNode;
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|