mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
97ecb5eb19
Summary: iOS and Android platform code already explicitly check this invariant: nodes cannot have parents when they're inserted into the View hierarchy. Check this in the core so we get these checks in unit tests, and earlier in the core before platform code runs. Changelog: [Internal] Reviewed By: shergin, mdvacca Differential Revision: D26331842 fbshipit-source-id: c12bc9066d280cb85ccc9e754c9fa475927e6080
64 lines
1.5 KiB
C++
64 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 <vector>
|
|
|
|
#include <react/renderer/core/LayoutMetrics.h>
|
|
#include <react/renderer/core/State.h>
|
|
#include <react/renderer/debug/debugStringConvertibleUtils.h>
|
|
#include <react/renderer/mounting/ShadowView.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
static const int NO_VIEW_TAG = -1;
|
|
|
|
class StubView final {
|
|
public:
|
|
using Shared = std::shared_ptr<StubView>;
|
|
|
|
StubView() = default;
|
|
StubView(StubView const &stubView) = default;
|
|
|
|
operator ShadowView() const;
|
|
|
|
void update(ShadowView const &shadowView);
|
|
|
|
ComponentName componentName;
|
|
ComponentHandle componentHandle;
|
|
SurfaceId surfaceId;
|
|
Tag tag;
|
|
SharedProps props;
|
|
SharedEventEmitter eventEmitter;
|
|
LayoutMetrics layoutMetrics;
|
|
State::Shared state;
|
|
std::vector<StubView::Shared> children;
|
|
Tag parentTag{NO_VIEW_TAG};
|
|
};
|
|
|
|
bool operator==(StubView const &lhs, StubView const &rhs);
|
|
bool operator!=(StubView const &lhs, StubView const &rhs);
|
|
|
|
#if RN_DEBUG_STRING_CONVERTIBLE
|
|
|
|
std::string getDebugName(StubView const &stubView);
|
|
|
|
std::vector<DebugStringConvertibleObject> getDebugProps(
|
|
StubView const &stubView,
|
|
DebugStringConvertibleOptions options);
|
|
std::vector<StubView> getDebugChildren(
|
|
StubView const &stubView,
|
|
DebugStringConvertibleOptions options);
|
|
|
|
#endif
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|