Fabric: Proper node construction in ComponentDescriptorRegistry

Summary: This is a very similar mechanism that we use in UIManager and it should be eventually unified.

Reviewed By: sammy-SC

Differential Revision: D16179524

fbshipit-source-id: 7c8c45b7581ac4a1db3a773d62004ff368f18321
This commit is contained in:
Valentin Shergin
2019-07-10 08:48:38 -07:00
committed by Facebook Github Bot
parent 12ca9830c8
commit e97a2a8535
@@ -143,16 +143,26 @@ SharedShadowNode ComponentDescriptorRegistry::createNode(
Tag tag,
std::string const &viewName,
SurfaceId surfaceId,
folly::dynamic const &props,
folly::dynamic const &propsDynamic,
SharedEventTarget const &eventTarget) const {
auto unifiedComponentName = componentNameByReactViewName(viewName);
auto const &componentDescriptor = this->at(unifiedComponentName);
auto const eventEmitter =
componentDescriptor.createEventEmitter(std::move(eventTarget), tag);
auto const props =
componentDescriptor.cloneProps(nullptr, RawProps(propsDynamic));
auto const state = componentDescriptor.createInitialState(
ShadowNodeFragment{surfaceId, tag, props, eventEmitter});
return componentDescriptor.createShadowNode({
/* .tag = */ tag,
/* .surfaceId = */ surfaceId,
/* .props = */ componentDescriptor.cloneProps(nullptr, RawProps(props)),
/* .eventEmitter = */
componentDescriptor.createEventEmitter(std::move(eventTarget), tag),
/* .props = */ props,
/* .eventEmitter = */ eventEmitter,
/* .children = */ ShadowNodeFragment::childrenPlaceholder(),
/* .localData = */ ShadowNodeFragment::localDataPlaceholder(),
/* .state = */ state,
});
}