Files
react-native/ReactCommon/fabric/core/state/StateTarget.cpp
T
Valentin Shergin b491e8725a Fabric: ShadowNode::getCommitedState() does not crash now in case if there is no comited state
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
2019-06-26 10:05:30 -07:00

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