File tree Expand file tree Collapse file tree 3 files changed +44
-10
lines changed
ReactCommon/fabric/element Expand file tree Collapse file tree 3 files changed +44
-10
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,14 @@ class ComponentBuilder final {
2929 ComponentBuilder (
3030 ComponentDescriptorRegistry::Shared const &componentDescriptorRegistry);
3131
32+ /*
33+ * Copyable and movable.
34+ */
35+ ComponentBuilder (ComponentBuilder const &componentBuilder) = default ;
36+ ComponentBuilder (ComponentBuilder &&componentBuilder) noexcept = default ;
37+ ComponentBuilder &operator =(ComponentBuilder const &other) = default ;
38+ ComponentBuilder &operator =(ComponentBuilder &&other) = default ;
39+
3240 /*
3341 * Builds a `ShadowNode` tree with given `Element` tree using stored
3442 * `ComponentDescriptorRegistry`.
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) Facebook, Inc. and its affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ */
7+
8+ #pragma once
9+
10+ #include < react/components/root/RootComponentDescriptor.h>
11+ #include < react/components/view/ViewComponentDescriptor.h>
12+ #include < react/element/ComponentBuilder.h>
13+ #include < react/uimanager/ComponentDescriptorProviderRegistry.h>
14+
15+ namespace facebook {
16+ namespace react {
17+
18+ extern ComponentBuilder simpleComponentBuilder () {
19+ ComponentDescriptorProviderRegistry componentDescriptorProviderRegistry{};
20+ auto eventDispatcher = EventDispatcher::Shared{};
21+ auto componentDescriptorRegistry =
22+ componentDescriptorProviderRegistry.createComponentDescriptorRegistry (
23+ ComponentDescriptorParameters{eventDispatcher, nullptr , nullptr });
24+
25+ componentDescriptorProviderRegistry.add (
26+ concreteComponentDescriptorProvider<RootComponentDescriptor>());
27+ componentDescriptorProviderRegistry.add (
28+ concreteComponentDescriptorProvider<ViewComponentDescriptor>());
29+
30+ return ComponentBuilder{componentDescriptorRegistry};
31+ }
32+
33+ } // namespace react
34+ } // namespace facebook
Original file line number Diff line number Diff line change 1212#include < react/components/view/ViewComponentDescriptor.h>
1313#include < react/element/ComponentBuilder.h>
1414#include < react/element/Element.h>
15+ #include < react/element/testUtils.h>
1516#include < react/uimanager/ComponentDescriptorProviderRegistry.h>
1617
1718using namespace facebook ::react;
1819
1920TEST (ElementTest, testNormalCases) {
20- ComponentDescriptorProviderRegistry componentDescriptorProviderRegistry{};
21- auto eventDispatcher = EventDispatcher::Shared{};
22- auto componentDescriptorRegistry =
23- componentDescriptorProviderRegistry.createComponentDescriptorRegistry (
24- ComponentDescriptorParameters{eventDispatcher, nullptr , nullptr });
25-
26- componentDescriptorProviderRegistry.add (
27- concreteComponentDescriptorProvider<ViewComponentDescriptor>());
28-
29- auto builder = ComponentBuilder{componentDescriptorRegistry};
21+ auto builder = simpleComponentBuilder ();
3022
3123 auto shadowNodeA = std::shared_ptr<ViewShadowNode const >{};
3224 auto shadowNodeAA = std::shared_ptr<ViewShadowNode const >{};
You can’t perform that action at this time.
0 commit comments