mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/34909 This Diff introduces a Sample component in RNTester which uses the NativeState to load some images. It is an example on how to use CustomNativeState In this first diff, I focused on the iOS side of things. The next diff will make this work with Android. ## Changelog [iOS][Added] - Introduce sample component which work with the native state. Reviewed By: cortinico Differential Revision: D39884926 fbshipit-source-id: 9323d751fd06a1bb8ff93af836d97010c2095833
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
/*
|
|
* 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.
|
|
*/
|
|
|
|
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
#include "RNTNativeComponentWithStateCustomShadowNode.h"
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/*
|
|
* Descriptor for <RNTNativeComponentWithStateCustomComponentDescriptor>
|
|
* component.
|
|
*/
|
|
class RNTNativeComponentWithStateCustomComponentDescriptor final
|
|
: public ConcreteComponentDescriptor<
|
|
RNTNativeComponentWithStateCustomShadowNode> {
|
|
public:
|
|
RNTNativeComponentWithStateCustomComponentDescriptor(
|
|
ComponentDescriptorParameters const ¶meters)
|
|
: ConcreteComponentDescriptor(parameters),
|
|
imageManager_(std::make_shared<ImageManager>(contextContainer_)) {}
|
|
|
|
void adopt(ShadowNode::Unshared const &shadowNode) const override {
|
|
ConcreteComponentDescriptor::adopt(shadowNode);
|
|
|
|
auto compShadowNode =
|
|
std::static_pointer_cast<RNTNativeComponentWithStateCustomShadowNode>(
|
|
shadowNode);
|
|
|
|
// `RNTNativeComponentWithStateCustomShadowNode` uses `ImageManager` to
|
|
// initiate image loading and communicate the loading state
|
|
// and results to mounting layer.
|
|
compShadowNode->setImageManager(imageManager_);
|
|
}
|
|
|
|
private:
|
|
const SharedImageManager imageManager_;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|