diff --git a/ReactCommon/fabric/element/Element.h b/ReactCommon/fabric/element/Element.h index 6c25b87d96c..d1056b56f02 100644 --- a/ReactCommon/fabric/element/Element.h +++ b/ReactCommon/fabric/element/Element.h @@ -48,6 +48,13 @@ class Element final { fragment_.props = ShadowNodeT::defaultSharedProps(); } + /* + * Converts to `ElementFragment` object. + */ + operator ElementFragment() { + return fragment_; + } + /* * Sets `tag`. */ @@ -83,11 +90,11 @@ class Element final { /* * Sets children. */ - Element &children(std::vector children) { + Element &children(std::vector children) { auto fragments = ElementFragment::List{}; fragments.reserve(children.size()); for (auto const &child : children) { - fragments.push_back(child.fragment_); + fragments.push_back(child); } fragment_.children = fragments; return *this; diff --git a/ReactCommon/fabric/element/tests/ElementTest.cpp b/ReactCommon/fabric/element/tests/ElementTest.cpp index 790759f3876..c3ecc1a6420 100644 --- a/ReactCommon/fabric/element/tests/ElementTest.cpp +++ b/ReactCommon/fabric/element/tests/ElementTest.cpp @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -20,7 +21,7 @@ using namespace facebook::react; TEST(ElementTest, testNormalCases) { auto builder = simpleComponentBuilder(); - auto shadowNodeA = std::shared_ptr{}; + auto shadowNodeA = std::shared_ptr{}; auto shadowNodeAA = std::shared_ptr{}; auto shadowNodeAB = std::shared_ptr{}; auto shadowNodeABA = std::shared_ptr{}; @@ -30,16 +31,15 @@ TEST(ElementTest, testNormalCases) { // clang-format off auto element = - Element() + Element() .reference(shadowNodeA) .tag(1) .props([]() { - auto props = std::make_shared(); - props->zIndex = 42; + auto props = std::make_shared(); props->nativeId = "node A"; return props; }) - .finalize([](ViewShadowNode &shadowNode){ + .finalize([](RootShadowNode &shadowNode){ shadowNode.sealRecursive(); }) .children({