mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
b491e8725a
Summary: `Target` inside the Stage can be empty; in this case, we should not try to extract `ShadowNode` from it. Reviewed By: JoshuaGross, mdvacca Differential Revision: D15982479 fbshipit-source-id: 83a4bebadc88b59d7fe77acbdf07e8ce9f2f6be1
30 lines
768 B
C++
30 lines
768 B
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.
|
|
*/
|
|
|
|
#include "StateTarget.h"
|
|
#include <react/core/ShadowNode.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
StateTarget::StateTarget() : shadowNode_(nullptr) {}
|
|
|
|
StateTarget::StateTarget(const ShadowNode &shadowNode)
|
|
: shadowNode_(shadowNode.shared_from_this()) {}
|
|
|
|
StateTarget::operator bool() const {
|
|
return (bool)shadowNode_;
|
|
}
|
|
|
|
const ShadowNode &StateTarget::getShadowNode() const {
|
|
assert(shadowNode_ && "Stored pointer to a ShadowNode must not be null.");
|
|
return *std::static_pointer_cast<const ShadowNode>(shadowNode_);
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|