mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: Making ComponentBuilder copyable and movable
Summary: It's useful property to have. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D19596280 fbshipit-source-id: 5b60cc4f7c65c3458ff35ffa2dfaafce79dc985a
This commit is contained in:
committed by
Facebook Github Bot
parent
b592c863ef
commit
42be1aad82
@@ -29,6 +29,14 @@ class ComponentBuilder final {
|
||||
ComponentBuilder(
|
||||
ComponentDescriptorRegistry::Shared const &componentDescriptorRegistry);
|
||||
|
||||
/*
|
||||
* Copyable and movable.
|
||||
*/
|
||||
ComponentBuilder(ComponentBuilder const &componentBuilder) = default;
|
||||
ComponentBuilder(ComponentBuilder &&componentBuilder) noexcept = default;
|
||||
ComponentBuilder &operator=(ComponentBuilder const &other) = default;
|
||||
ComponentBuilder &operator=(ComponentBuilder &&other) = default;
|
||||
|
||||
/*
|
||||
* Builds a `ShadowNode` tree with given `Element` tree using stored
|
||||
* `ComponentDescriptorRegistry`.
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <react/components/root/RootComponentDescriptor.h>
|
||||
#include <react/components/view/ViewComponentDescriptor.h>
|
||||
#include <react/element/ComponentBuilder.h>
|
||||
#include <react/uimanager/ComponentDescriptorProviderRegistry.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
extern ComponentBuilder simpleComponentBuilder() {
|
||||
ComponentDescriptorProviderRegistry componentDescriptorProviderRegistry{};
|
||||
auto eventDispatcher = EventDispatcher::Shared{};
|
||||
auto componentDescriptorRegistry =
|
||||
componentDescriptorProviderRegistry.createComponentDescriptorRegistry(
|
||||
ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr});
|
||||
|
||||
componentDescriptorProviderRegistry.add(
|
||||
concreteComponentDescriptorProvider<RootComponentDescriptor>());
|
||||
componentDescriptorProviderRegistry.add(
|
||||
concreteComponentDescriptorProvider<ViewComponentDescriptor>());
|
||||
|
||||
return ComponentBuilder{componentDescriptorRegistry};
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
@@ -12,21 +12,13 @@
|
||||
#include <react/components/view/ViewComponentDescriptor.h>
|
||||
#include <react/element/ComponentBuilder.h>
|
||||
#include <react/element/Element.h>
|
||||
#include <react/element/testUtils.h>
|
||||
#include <react/uimanager/ComponentDescriptorProviderRegistry.h>
|
||||
|
||||
using namespace facebook::react;
|
||||
|
||||
TEST(ElementTest, testNormalCases) {
|
||||
ComponentDescriptorProviderRegistry componentDescriptorProviderRegistry{};
|
||||
auto eventDispatcher = EventDispatcher::Shared{};
|
||||
auto componentDescriptorRegistry =
|
||||
componentDescriptorProviderRegistry.createComponentDescriptorRegistry(
|
||||
ComponentDescriptorParameters{eventDispatcher, nullptr, nullptr});
|
||||
|
||||
componentDescriptorProviderRegistry.add(
|
||||
concreteComponentDescriptorProvider<ViewComponentDescriptor>());
|
||||
|
||||
auto builder = ComponentBuilder{componentDescriptorRegistry};
|
||||
auto builder = simpleComponentBuilder();
|
||||
|
||||
auto shadowNodeA = std::shared_ptr<ViewShadowNode const>{};
|
||||
auto shadowNodeAA = std::shared_ptr<ViewShadowNode const>{};
|
||||
|
||||
Reference in New Issue
Block a user