mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-03 23:35:06 +08:00
Summary: This allows an unsupported component to be rendered as a "unimplemented view" for better visualization of which component is missing. It is off by default, but configurable in the component factory. For now, the layout simply follows regular <View />, which means the width/height etc is based on the react component styling. The side effect is that components with 0 height/width won't show up at all. Reviewed By: mdvacca Differential Revision: D14869656 fbshipit-source-id: f31e012fb7dc1c64fcc431ea5aa45079a23a618e
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
// 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 <memory>
|
|
|
|
#include <better/map.h>
|
|
#include <react/core/ComponentDescriptor.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
class ComponentDescriptorRegistry;
|
|
|
|
using SharedComponentDescriptorRegistry =
|
|
std::shared_ptr<const ComponentDescriptorRegistry>;
|
|
|
|
/*
|
|
* Registry of particular `ComponentDescriptor`s.
|
|
*/
|
|
class ComponentDescriptorRegistry {
|
|
public:
|
|
void registerComponentDescriptor(
|
|
SharedComponentDescriptor componentDescriptor);
|
|
|
|
const ComponentDescriptor &at(ComponentName componentName) const;
|
|
const ComponentDescriptor &at(ComponentHandle componentHandle) const;
|
|
|
|
const SharedComponentDescriptor operator[](
|
|
const SharedShadowNode &shadowNode) const;
|
|
const SharedComponentDescriptor operator[](
|
|
const ComponentName &componentName) const;
|
|
SharedShadowNode createNode(
|
|
Tag tag,
|
|
const std::string &viewName,
|
|
Tag rootTag,
|
|
const folly::dynamic &props,
|
|
const SharedEventTarget &eventTarget) const;
|
|
void setFallbackComponentDescriptor(SharedComponentDescriptor descriptor);
|
|
const SharedComponentDescriptor getFallbackComponentDescriptor() const;
|
|
|
|
private:
|
|
better::map<ComponentHandle, SharedComponentDescriptor> _registryByHandle;
|
|
better::map<ComponentName, SharedComponentDescriptor> _registryByName;
|
|
SharedComponentDescriptor _fallbackComponentDescriptor;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|