mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Delete ComponentDeprecatedAPI
Summary: Deletes references to ComponentDeprecatedAPI in favour of Component API changelog: [internal] internal Reviewed By: rshest Differential Revision: D41638892 fbshipit-source-id: c83b2303650475aa59b438e46e96f976db586a27
This commit is contained in:
committed by
Facebook GitHub Bot
parent
30d50430a9
commit
d9e7be76cd
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Meta Platforms, Inc. and 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/renderer/core/Props.h>
|
||||
#include <react/renderer/core/ReactPrimitives.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace facebook::react {
|
||||
|
||||
class ComponentDeprecatedAPI {
|
||||
public:
|
||||
ComponentDeprecatedAPI(Tag tag, Props::Shared initialProps)
|
||||
: tag_(tag), props_(std::move(initialProps)) {}
|
||||
|
||||
virtual ~ComponentDeprecatedAPI() = default;
|
||||
|
||||
/*
|
||||
* Called for updating component's props.
|
||||
* Receiver must update native view props accordingly changed props.
|
||||
*/
|
||||
virtual void updateProps(
|
||||
Props::Shared const &oldProps,
|
||||
Props::Shared const &newProps) = 0;
|
||||
|
||||
/*
|
||||
* Called for mounting (attaching) a child component view inside `self`
|
||||
* component view.
|
||||
* Receiver must add `childComponent` as a sub component.
|
||||
*/
|
||||
virtual void mountChildComponent(
|
||||
std::shared_ptr<facebook::react::ComponentDeprecatedAPI> childComponent,
|
||||
int index){};
|
||||
|
||||
/*
|
||||
* Called for unmounting (detaching) a child component view from `self`
|
||||
* component view.
|
||||
* Receiver must remove `childComponent` from a sub component
|
||||
*/
|
||||
virtual void unmountChildComponent(
|
||||
std::shared_ptr<facebook::react::ComponentDeprecatedAPI> childComponent,
|
||||
int index){};
|
||||
|
||||
/*
|
||||
* Called for updating component's state.
|
||||
* Receiver must update native view according to changed state.
|
||||
*/
|
||||
virtual void updateState(){};
|
||||
|
||||
protected:
|
||||
Tag tag_ = -1;
|
||||
Props::Shared props_;
|
||||
};
|
||||
|
||||
} // namespace facebook::react
|
||||
@@ -8,7 +8,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <react/cxxcomponents/Component.h>
|
||||
#include <react/cxxcomponents/ComponentDeprecatedAPI.h>
|
||||
#include <react/renderer/core/Props.h>
|
||||
|
||||
namespace facebook::react {
|
||||
@@ -17,10 +16,6 @@ class ComponentManager {
|
||||
public:
|
||||
ComponentManager() {}
|
||||
|
||||
virtual std::shared_ptr<ComponentDeprecatedAPI> createComponent(
|
||||
Tag tag,
|
||||
Props::Shared initialProps) = 0;
|
||||
|
||||
virtual std::shared_ptr<Component> createComponent(Tag tag) = 0;
|
||||
|
||||
virtual ~ComponentManager() = default;
|
||||
|
||||
@@ -42,30 +42,9 @@ CppComponentRegistry::getComponentManager(const std::string &name) const {
|
||||
return componentManagerResolver_.getComponentManager(name);
|
||||
}
|
||||
|
||||
std::shared_ptr<facebook::react::ComponentDeprecatedAPI>
|
||||
CppComponentRegistry::getComponentInstance(Tag tag) const {
|
||||
return components_[tag];
|
||||
}
|
||||
|
||||
bool CppComponentRegistry::isRootComponent(std::string name) const {
|
||||
return componentManagerResolver_.isRootComponent(name);
|
||||
}
|
||||
|
||||
std::shared_ptr<facebook::react::ComponentDeprecatedAPI>
|
||||
CppComponentRegistry::createComponentInstance(
|
||||
const std::string &componentName,
|
||||
Tag tag,
|
||||
Props::Shared initialProps) const {
|
||||
// TODO: cache component managers
|
||||
auto componentManager = getComponentManager(componentName);
|
||||
auto component = componentManager->createComponent(tag, initialProps);
|
||||
components_[tag] = component;
|
||||
return component;
|
||||
}
|
||||
|
||||
void CppComponentRegistry::deleteComponentInstance(Tag tag) const {
|
||||
components_.erase(tag);
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
#include <react/cxxcomponents/ComponentDeprecatedAPI.h>
|
||||
#include <react/cxxcomponents/ComponentManager.h>
|
||||
#include <react/fabric/ComponentRegistryResolver.h>
|
||||
|
||||
@@ -43,23 +42,11 @@ class CppComponentRegistry : public jni::HybridClass<CppComponentRegistry> {
|
||||
std::shared_ptr<facebook::react::ComponentManager> getComponentManager(
|
||||
const std::string &name) const;
|
||||
|
||||
std::shared_ptr<facebook::react::ComponentDeprecatedAPI> getComponentInstance(
|
||||
Tag tag) const;
|
||||
|
||||
std::shared_ptr<facebook::react::ComponentDeprecatedAPI>
|
||||
createComponentInstance(
|
||||
const std::string &componentName,
|
||||
Tag tag,
|
||||
Props::Shared initialProps) const;
|
||||
|
||||
void deleteComponentInstance(Tag tag) const;
|
||||
|
||||
private:
|
||||
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jclass>);
|
||||
ComponentRegistryResolver componentManagerResolver_{};
|
||||
mutable butter::
|
||||
map<Tag, std::shared_ptr<facebook::react::ComponentDeprecatedAPI>>
|
||||
components_{};
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
|
||||
Reference in New Issue
Block a user