From e97a2a853558e7aea1dd73276968ff73435866ff Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Wed, 10 Jul 2019 08:44:52 -0700 Subject: [PATCH] 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 --- .../uimanager/ComponentDescriptorRegistry.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp b/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp index b6fd46ff537..1b6033487fa 100644 --- a/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp +++ b/ReactCommon/fabric/uimanager/ComponentDescriptorRegistry.cpp @@ -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, }); }