Files
react-native/ReactCommon/fabric/core/state/StateTarget.cpp
T
Samuel Susla 7796b7e9af Avoid use of shared_from_this in StateTarget
Summary:
`StateTarget` no longer uses `shared_from_this`, this allows us to remove need for `enable_shared_from_this`

I decided to put `state->commit` call inside `ShadowTree.cpp` because I needed to have access to `shared_ptr` of shadow node from outside of the class itself.
`state->commit` was originally designed to be only called by `ShadowNode` but this does not seem to be the case anymore since it is called from `UIManager` as well.

changelog: [internal]

Reviewed By: shergin

Differential Revision: D18032532

fbshipit-source-id: 75c874fd04f86adc07bfddbef3a0384e17c2067b
2019-10-21 17:18:36 -07:00

30 lines
720 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(std::shared_ptr<ShadowNode const> shadowNode)
: shadowNode_(shadowNode) {}
StateTarget::operator bool() const {
return (bool)shadowNode_;
}
const ShadowNode &StateTarget::getShadowNode() const {
assert(shadowNode_ && "Stored pointer to a ShadowNode must not be null.");
return *shadowNode_;
}
} // namespace react
} // namespace facebook